Is there a mapping file for R8-minimized android resource files?

81 Views Asked by At

In the case of a minimized but not obfuscated APK, R8 still scrambles the resource file names in the R8 build step. The APK, when unzipped, have resource file names like 0c9.png, 0F.xml and 1g.xml, while the original names were button_blue.xml, button_red.xml etc.

Is there any way to reverse-map these back to identifiable resource file names?

I looked through the build output to see if there were mapping files generated for this kind of renaming but I couldn't find anything. mapping.txt only applies to Kotlin/Java code. resources.txt seems to be about usage, not renmaing.

Optionally, is there a way to minimize resources without renaming the files?

My build gradle for the release build

release {
    minifyEnabled true
    shrinkResources true
    proguardFiles getDefaultProguardFile('proguard-android.txt'), '../proguard-rules.pro'
    signingConfig signingConfigs.release
}

My proguard file ../proguard-rules.pro contains this line

-dontobfuscate
1

There are 1 best solutions below

0
sgjesse On

From https://issuetracker.google.com/316831822#comment2:

This is not R8, and it is not resource shrinker either, this is renamed by the resource name shortener in AAPT2 (that agp invokes by default)

If you want to know what the original name of say res/Z.png is you can do:

aapt2 dump resources my.apk | grep "res/Z.png"