JakeWharton / diffuse

Diffuse is a tool for diffing APKs, AABs, AARs, and JARs
Apache License 2.0
1.96k stars 102 forks source link

Exception in thread "main" org.w3c.dom.DOMException: NAMESPACE_ERR: An attempt is made to create or change an object in a way which is incorrect with regard to namespaces. #112

Open mSharif10 opened 2 years ago

mSharif10 commented 2 years ago

Tried to run the diffuse but it returns the above error.

the command used

java -jar diffuse.jar diff "apk1" "apk2"

the apk in question can be found here

the error trace here: at com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.checkNamespaceWF(CoreDocumentImpl.java:2535) at com.sun.org.apache.xerces.internal.dom.AttrNSImpl.setName(AttrNSImpl.java:93) at com.sun.org.apache.xerces.internal.dom.AttrNSImpl.<init>(AttrNSImpl.java:78) at com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.createAttributeNS(CoreDocumentImpl.java:2164) at com.sun.org.apache.xerces.internal.dom.ElementImpl.setAttributeNS(ElementImpl.java:659) at com.jakewharton.diffuse.Manifest$Companion.toManifest$diffuse(Manifest.kt:974) at com.jakewharton.diffuse.Apk$Companion.parse(Apk.kt:124) at com.jakewharton.diffuse.DiffCommand.run(diffuse.kt:117) at com.github.ajalt.clikt.parsers.Parser.parse(Parser.kt:5266) at com.github.ajalt.clikt.parsers.Parser.parse(Parser.kt:5274) at com.github.ajalt.clikt.core.CliktCommand.parse$default(CliktCommand.kt:281) at com.jakewharton.diffuse.Diffuse.main(diffuse.kt:23324) although I am not sure it is about the xml naming issue? How can I solve this?

mateuszkwiecinski commented 2 years ago

@mSharif10 I tried to parse your apk and none of the online parsers nor AndroidStudio was able to parse it correctly 🤔

I'm getting either

error: trying to add resource 'com.safarifone.waafi:anim/' with ID 0x7f010001 but resource already has ID 0x7f010000.

or in AS:

image

Moreover, manually parsing your apk with aapt produces AndroidManifest.xml that contains an invalid entry android:="true" which also isn't valid xml:

image

I might have generated a corrupted apk, but it produces exactly the same stack trace. Diffuse fails to obtain attribute namespace here: https://github.com/JakeWharton/diffuse/blob/7481ff5f5a8af07de13bb4b5a12e509873fa970f/formats/src/main/kotlin/com/jakewharton/diffuse/format/AndroidManifest.kt#L98