使用ProGuard和XmlPullParser问题 [英] Problem with Proguard and XmlPullParser

查看:293
本文介绍了使用ProGuard和XmlPullParser问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有在Android项目有点麻烦,使用Proguard的一些库。具体而言,我有一个XmlPullParser碰撞,而无论我似乎做,我似乎无法来解决它。下面是我使用的库:

I'm having a bit of trouble on an Android project using Proguard with some libraries. Specifically, i'm having an XmlPullParser collision, and no matter what i seem to do, i can't seem to solve it. Here are the libraries I am using:

JacksonParser,包括:

  • 杰克逊all.1.6.4.jar
  • 乔达-time.1.6.2.jar
  • JS​​R311-API-1.0.jar
  • stax2-API-3.0.0.jar

XStream的,其中包括

  • xpp3_min-1.1.4c.jar
  • XStream的换机器人-1.0.0.jar

也有其他人,但他们是一个不是问题的问题。这似乎是我们问题的罪魁祸首。

There are also others, but they're a non-issue. These seem to be the culprit of our problems.

具体而言,问题是:

优化

如果我做了一个优化,我得到转换为Dalvik的失败,1。有一个帖子专门对此的<一个href="http://stackoverflow.com/questions/2680827/conversion-to-dalvik-format-failed-with-error-1-on-external-jar">"Conversion到的Dalvik格式失败,错误1&QUOT;外部罐,其中指出我有一个重复XmlPullParser类的方向。这是有道理的,因为XStream的使用app3_min-1.1.4c.jar,其中包括具有比列入的android.jar一个更好的/附加功能的XmlPullParser。正因为如此,我已经尝试了通配符xmlpull **去除的android.jar:

if i do an optimization, i get "conversion to dalvik failed with 1". There is a post specifically about this at "Conversion to Dalvik format failed with error 1" on external Jar, which pointed me in the direction of having a duplicate XmlPullParser class. This makes sense, since XStream uses app3_min-1.1.4c.jar, which includes an XmlPullParser that has better/additional functionality than the one included in the android.jar. as such, i've tried a wildcard xmlpull** removal from android.jar:

-libraryjars <java.home>/lib/rt.jar;C:/Android/platforms/android-9/android.jar(!org/xmlpull/v1/**)

和我也试了明确删除它们:

and i've also tried explicitly removing them:

-libraryjars <java.home>/lib/rt.jar;C:/Android/platforms/android-9/android.jar(!org/xmlpull/v1/XmlPullParser.class,!org/xmlpull/v1/XmlPullParserException.class,!org/xmlpull/v1/XmlPullParserFactory,!org/xmlpull/mxp1/MXParser)

但既不是修复有帮助。

but neither fix has helped.

别急,还有更精彩(大约在同一问题的所有中心的,所以我想如果我能解决这个问题,别人走)。

but wait, there's more (all centered around the same issue though, so i think if i solve this one, the others go away).

混淆

如果我试图混淆视听,我得到以下运行时错误:

If i try to obfuscate, i get the following runtime error:

java.lang.NoSuchMethodError: android.content.res.XmlResourceParser.s
looking this up in the mapping, i get: .s = abstract int next()

所以它缺少next()方法。那么,为什么这种方法缺少什么?我听不懂。我甚至尝试这样做:

so it's missing the next() method. so why is that method missing? i don't understand. i even tried doing this:

-keep class android.content.res.XmlResourceParser { int next(); }

要确保方法获取preserved,但我仍然得到了同样的问题。

to make sure that method gets preserved, but still i get the same issue.

收缩

萎缩问题似乎也是失败。在应用程序启动,但从来没有得到任何地方,它只是不停地尝试了个遍推出的第一项活动,并给我一个无用的错误。我不那么担心这个尚未虽然,我可以生活在没有缩水,如果我能得到的混淆和优​​化工作。

Shrinking also seems to fail. the app launches but never gets anywhere, it just keeps trying to launch the first activity over and over and giving me a useless error. i'm not so worried about this yet though, i can live without shrinking, if i can get obfuscation and optimization working.

更多信息

作为一个参考点,我试图引用我的库两种方式,第一种是使用injars:

As a point of reference, i've tried to reference my libraries two ways, the first is using injars:

-injars ReferencedAssemblies/XStream/xpp3_min-1.1.4c.jar(!META-INF/MANIFEST.MF)
-injars ReferencedAssemblies/JacksonParser/jackson-all-1.6.4.jar(!META-INF/MANIFEST.MF,!META-INF/ASL2.0,!META-INF/LICENSE,!META-INF/NOTICE)
-injars ReferencedAssemblies/JacksonParser/joda-time-1.6.2.jar(!META-INF/MANIFEST.MF)
-injars ReferencedAssemblies/JacksonParser/jsr311-api-1.0.jar(!META-INF/MANIFEST.MF)
-injars ReferencedAssemblies/JacksonParser/stax2-api-3.0.0.jar(!META-INF/MANIFEST.MF)
-injars ReferencedAssemblies/XStream/xstream-for-android-1.0.0.jar(!META-INF/MANIFEST.MF)

这甚至不会建立。

我也做到了这一点:

-libraryjars <java.home>/lib/rt.jar
  ;C:/Android/platforms/android-9/android.jar(!org/xmlpull/v1/**)
  #;C:/Android/platforms/android-9/android.jar(!org/xmlpull/v1/XmlPullParser.class,!org/xmlpull/v1/XmlPullParserException.class,!org/xmlpull/v1/XmlPullParserFactory,!org/xmlpull/mxp1/MXParser)
  ;ReferencedAssemblies/JacksonParser/jackson-all-1.6.4.jar(!META-INF/MANIFEST.MF,!META-INF/ASL2.0,!META-INF/LICENSE,!META-INF/NOTICE)
  ;ReferencedAssemblies/JacksonParser/joda-time-1.6.2.jar(!META-INF/MANIFEST.MF)
  ;ReferencedAssemblies/JacksonParser/jsr311-api-1.0.jar(!META-INF/MANIFEST.MF)
  ;ReferencedAssemblies/JacksonParser/stax2-api-3.0.0.jar(!META-INF/MANIFEST.MF)
  ;ReferencedAssemblies/XStream/xpp3_min-1.1.4c.jar(!META-INF/MANIFEST.MF)

这让我最远的,我能够导出APK,如果我不优化。

this gets me the furthest, i'm able to export an APK if i don't optimize.

我也做到了这一点:

-dontwarn org.xmlpull.v1.**

因为这似乎是一个已知的问题(见previous链接)

since this seems to be a known issue (see previous link)

任何人有什么样是怎么回事任何想法或如何解决呢?我有一种感觉,这已经是与我是同时使用XStream和JacksonParser的事实,也许JacksonParser图书馆之一也有一个XmlPullParser的呢?问题是,这可以解释优化的错误,而不是混淆错误。我不知道在那一个。为什么会不会被发现的方法,甚至的,如果我明确preserved呢?

Anyone have any idea of what's going on here or how i solve it? i have a feeling that this has something to do with the fact that i'm using both XStream and JacksonParser, and perhaps one of the JacksonParser libraries also has an XmlPullParser in it? The thing is, that would explain the optimization error, but not the obfuscation error. i have no idea on that one. why would it not be finding that method, even if i've explicitly preserved it?

谢谢大家。

推荐答案

这对我的作品:

-dontwarn org.xmlpull.v1.**
-dontnote org.xmlpull.v1.**
-keep class org.xmlpull.** { *; }

这篇关于使用ProGuard和XmlPullParser问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆