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, includes:
- Jackson-all.1.6.4.jar
- Joda-time.1.6.2.jar
- jsr311-api-1.0.jar
- stax2-api-3.0.0.jar
XStream, which includes:
- xpp3_min-1.1.4c.jar
- xstream-for-android-1.0.0.jar
There are also others, but they're a non-issue. These seem to be the culprit of our problems.
Specifically, the issues are:
Optimization
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).
Obfuscation
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()
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(); }
to make sure that method gets preserved, but still i get the same issue.
Shrinking
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.
More Info
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)
this won't even build.
i've also done this:
-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)
this gets me the furthest, i'm able to export an APK if i don't optimize.
i've also done this:
-dontwarn org.xmlpull.v1.**
since this seems to be a known issue (see previous link)
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?
thanks all.