MightyCreak / diffuse

Diffuse is a graphical tool for comparing and merging text files. It can retrieve files for comparison from Bazaar, CVS, Darcs, Git, Mercurial, Monotone, RCS, Subversion, and SVK repositories.
http://mightycreak.github.io/diffuse/
GNU General Public License v2.0
265 stars 45 forks source link

IllegalStateException parsing APKs with no resource table. In AGP 7, android-test APKs will have no resource table if androidTest/res is empty #124

Closed autonomousapps closed 2 years ago

autonomousapps commented 2 years ago

In AGP 7, if you execute (e.g.)

./gradlew lib:assembleDebugAndroidTest

on an Android library project that doesn't have any resources (no androidTest/res directory), and then attempt to compare that APK with one built with AGP 4, you'll get an error like this:

$ diffuse diff --apk test4.apk test7.apk
Exception in thread "main" java.lang.IllegalStateException: ResourceTableChunk package count was < 1.
        at com.android.apksig.ApkSigner.checkState(ApkSigner.java:1)
        at com.google.devrel.gmscore.tools.apk.arsc.ResourceTableChunk.<init>(ResourceTableChunk.java:7)
        at com.google.devrel.gmscore.tools.apk.arsc.Chunk.newInstance(Chunk.java:57)
        at com.jakewharton.diffuse.Arsc$Companion.create(Arsc.kt:42)
        at com.jakewharton.diffuse.Apk$Companion.parse(Apk.kt:84)
        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)

Note that this issue arises regardless of whether the library project uses

android.buildFeatures.androidResources = false

That value appears to be ignored, at least in AGP 7.0.3. The mere presence of a resource in androidrTest/res can workaround this issue.

apktool has a similar issue when executing apktool d path/to/apk -o foo, but there's a CLI option, -r, that solves the problem: apktool -r d path/to/apk -o foo.

MightyCreak commented 2 years ago

I don't think this is related to diffuse... are you sure you've submitted an issue on the repository you wanted?

autonomousapps commented 2 years ago

oh dear god this is the wrong diffuse. I am SO sorry. (hope you get a laugh, though)

MightyCreak commented 2 years ago

Hahaha no worries :wink: You got me puzzled though :sweat_smile:

autonomousapps commented 2 years ago

in case you're curious about your github twin https://github.com/JakeWharton/diffuse/issues/104