Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ProGuard doesn't generate mapping file

I have read multiple threads on SO but couldn't find any answer. I have multiple questions here. Let me describe:

  • I don't know much about ProGuard but according to my information, it obfuscates the Android code to some extent. My question is Do I need to enable it somewhere? minifyEnabled is false in my Gradle file. Does this disable ProGuard completely?
  • To deobfuscate the crash on Firebase and get stack trace, I need the mapping file. I can't find it anywhere. In app/build/outputs folder, I only have

Folder

Then I read somewhere about proguard-rules.pro file. It just had some comments and no code. Then I put this in it: -printmapping mapping.txt. Then generated signed APK again, still no success. What am I missing?

Edit 1: If I have to execute some adb terminal command, please describe steps. I have never used Terminal before.

like image 727
Paras Sidhu Avatar asked Aug 05 '16 07:08

Paras Sidhu


People also ask

Where is the ProGuard config file?

By default, this file is located at the root of the module (next to the build. gradle file).

What does minifyEnabled do?

In the release block on the example, minifyEnabled refers to the automatic removal of unused resources in the packaged app. If true, Gradle also removes resources from dependent libraries if they are not needed. This only works if the shrinkResources property is also set to true.


3 Answers

try to check setting -> InstantRun... it must be disabled :)

like image 34
strajky Avatar answered Sep 29 '22 07:09

strajky


In your gradle file you must specifically set the minifyEnabled option to true.
This enables obfuscation. By doing so, it also applies the obfuscation rules that you define on your 'proguard-rules.pro' file.

buildTypes {
    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

You can print the mapping and the seeds used (note that you need both to fully decode/understand the encrypted code) by applying the respective commands

-printseeds obfuscation/seeds.txt

and

-printmapping obfuscation/mapping.txt

An example of a basic proguard file is :

-optimizationpasses 5
-dontpreverify
-repackageclasses ''
-allowaccessmodification
-optimizations !code/simplification/arithmetic
-keepattributes *Annotation*

-verbose

-dump obfuscation/class_files.txt
-printseeds obfuscation/seeds.txt
-printusage obfuscation/unused.txt
-printmapping obfuscation/mapping.txt

Regards,

like image 124
Ricardo Vieira Avatar answered Sep 29 '22 05:09

Ricardo Vieira


  1. Set minifyEnabled to true.
  2. Build generate APK.
  3. Look in the outputs folder for mappings file.[Don't Clean Project or it will be gone]
like image 5
Arnav M. Avatar answered Sep 29 '22 06:09

Arnav M.