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,
XML parsing can be a real pain on Android. I recently ran into similar issues when trying to use Jackson XML data binding on Android.
I ended up using the tool Jar Jar Links to move the conflicting classes in the libraries I was trying to use to a new package name that doesn't conflict with the Android platform classes:
http://code.google.com/p/jarjar/
You can tell Jar Jar Links to find the namespaces in the XML library JAR files that we provide that conflict with Android (i.e., javax.xml.stream.*
), and have JarJar rename them to something that doesn't conflict (i.e., edu.usf.cutr.javax.xml.stream.*
). Android will then accept the libraries that doesn't conflict without the Conversion to Dalvik format failed with error 1
.
Here's a zip file that includes files I used to do a batch conversion of the XML libraries I needed, which were:
The generate_android_jarsv21.bat
batch file is included to automate the conversion process using JarJar for multiple XML library JARs at once.
JarJar uses a series of rules to change the namespaces in the JAR files. Here's the contents of my rules.txt file that renames all occurences of javax.xml.stream.*
to edu.usf.cutr.javax.xml.stream.*
:
rule javax.xml.stream.** edu.usf.cutr.javax.xml.stream.@1
You should be able to follow a similar process for the XML libraries you're working with. Once the collision in packages is resolved by moving the library classes to a new package, the other down-stream issues with Proguard should resolve themselves.
I wrote a full tutorial here that includes more detail on "Modifying XML libraries for Android":
https://github.com/CUTR-at-USF/SiriRestClient/wiki/Modifying-XML-libraries-for-Android