androidproguardbuildconfigandroid-buildconfig

Where can I find my BuildConfig in the APK analyzer after minifying the code with ProGuard?


Please take a look at the following two images from Analyze APK on Android Studio.

enter image description here
minifyEnabled = false. BuildConfig is there.

enter image description here
minifyEnabled = true (decoded with mapping.txt). BuildConfig is not there.

I can find BuildConfig in classes.dex before minifying, but not after minifying. I can't find any document/discussion about this, but is there some rule to strip BuildConfig from classes.dex after minifying with ProGuard? In that case, does it mean that it is relatively safe to put sensitive information in BuildConfig? Or, probably it is just hidden in some other place?

My ProGuard version is 4.7 if that matters.


Solution

  • An additional feature of the minifying step is the inlining of constants. This would explain why the BuildConfig disappears, and yet the values still exist where needed. Once the values get inlined, there are no more references to the BuildConfig class and the minifier can remove it entirely.