Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

  • First one is with minifyEnabled = false, and
  • another one is with minifyEnabled = true (after decoding with mapping.txt of course)

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.

like image 891
barley Avatar asked May 27 '19 01:05

barley


People also ask

Where is BuildConfig generated?

There's a class called BuildConfig. java which is automatically generated by the build system. This class is updated automatically by Android's build system (like the R class). It already contains a static final boolean called DEBUG, which is normally set to true.

How do I analyze an APK file?

Drag an APK or app bundle into the Editor window of Android Studio. Switch to the Project perspective in the Project window and then double-click the APK in the default build/output/apks/ directory. Select Build > Analyze APK in the menu bar and then select your APK or app bundle.

How do you check if APK is debug or release programmatically?

Open your command prompt, write below line of code and execute. If you find this output, then its a debug build as it is written “CN=Android Debug”.


1 Answers

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.

like image 86
David Liu Avatar answered Oct 26 '22 07:10

David Liu