I am trying to use apktool to decompile apk files using the command shown below but it is not able to decode the Android manifest and throws an exception. I have tested it with different apps and get the same exception always. I have the jar of xmlpull-1.1.3.1, xmlpull_1_0_5, and kxml2 in my jre lib path (i.e., /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/ext/) and I have included these paths in the CLASSPATH. How do I resolve this please?
apktool d uk.co.houseoffraser.apk
I: Using Apktool 2.3.0 on uk.co.houseoffraser.apk
I: Loading resource table...
I: Decoding AndroidManifest.xml with resources...
Exception in thread "main" brut.androlib.AndrolibException: Could not decode XML at brut.androlib.res.decoder.XmlPullStreamDecoder.decode(XmlPullStreamDecoder.java:145) at brut.androlib.res.decoder.XmlPullStreamDecoder.decodeManifest(XmlPullStreamDecoder.java:153) at brut.androlib.res.decoder.ResFileDecoder.decodeManifest(ResFileDecoder.java:140) at brut.androlib.res.AndrolibResources.decodeManifestWithResources(AndrolibResources.java:209) at brut.androlib.Androlib.decodeManifestWithResources(Androlib.java:137) at brut.androlib.ApkDecoder.decode(ApkDecoder.java:113) at brut.apktool.Main.cmdDecode(Main.java:160) at brut.apktool.Main.main(Main.java:72)
Caused by: org.xmlpull.v1.XmlPullParserException: could not load any factory class (even small or full default implementation); nested exception is: org.kxml2.io.XmlReader at org.xmlpull.v1.XmlPullParserFactory.newInstance(XmlPullParserFactory.java:225) at org.xmlpull.v1.XmlPullParserFactory.newInstance(XmlPullParserFactory.java:76) at org.xmlpull.v1.wrapper.XmlPullWrapperFactory.(XmlPullWrapperFactory.java:52) at org.xmlpull.v1.wrapper.XmlPullWrapperFactory.newInstance(XmlPullWrapperFactory.java:29) at brut.androlib.res.decoder.XmlPullStreamDecoder.decode(XmlPullStreamDecoder.java:49) ... 7 more
I finally discovered that the xmlpull jar e.g., xmlpull-1.1.3.1.jar, xmlpull_1_0_5.jar is the default xml parser that is always used even if you only have the KXML2 parser in your CLASSPATH. Removing the xmlpull parser from the jre extended library (e.g., /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/ext/) fixes the problem. Even if the CLASSPATH have other xml parsers, as long as only the KXML2 jar is in the jre library, it works.