Where does Android Studio save the ProGuard mapping file?
Solution 1
It should be located at build/outputs/proguard/release/mapping.txt
in your application module's directory.
In the latest version of ProGuard and Android Studio, the file is located at build/outputs/mapping/release/mapping.txt
.
Solution 2
For me they are at 'build/outputs/mapping/release'
Solution 3
I found it cleaner to configure proguard to write the mapping.txt file to a location outside of the build/
directory tree, so that it could be more conveniently checked into version control.
To achieve this, put this in your proguard-rules.pro
file:
-printmapping mapping.txt
This will (most likely) place it in the same directory as your proguard-rules.pro
file. Ultimately, you probably want to write it to the same directory as your APK file and with an equivalent name (which might include flavor, build type etc).
Note: in my experience, this is not overruled by the proguard template file (which was suggested by a commenter to another answer here).
UPDATE: If you have multiple product flavors, then this is a much better solution: https://stackoverflow.com/a/31116608/444761
Solution 4
I found that it was not being generated, so I added this to the rules file
-printmapping build/outputs/mapping/release/mapping.txt
Solution 5
Its quite late to answer this question but just in case someone need my answer.
Location of Mapping file to deobfuscate:
ProGuard saves the file in the app app/build/outputs/mapping/FLAVOR/release/mapping.txt
Generally in debug mode you don't need the mapping file because there generally obfuscation is disabled. If it is not that case then make sure in build.gradle file you have below code for debug variant.
debug {
minifyEnabled false
debuggable true
}
Some Gotchas:
mapping.txt file gets overwritten every time you create a release build with ProGuard, so first take backup of that file before creating a new release. It will help to obfuscated stack trace from an older version of your app.
Apart from that there are two ways to obfuscate your code :
1. Upload your mapping.txt file to Google play Console:
When publishing your app on Google Play, you can upload the mapping.txt file for each version of your APK. Then Google Play will deobfuscate incoming stack traces from user-reported issues so you can review them in the Google Play Console.
2. Use local sdk tool retrace.sh/retrace.bat:
Some times you want to run the release version of your app(by changing build variant to release and running it) to cross check and fix the errors so that it does not happens in production ( when released to play-store).
To convert an obfuscated stack-trace to a readable one yourself, use the retrace script (retrace.bat on Windows; retrace.sh on Mac/Linux).
It is located in the <sdk-root>/tools/proguard/bin/
directory.
<sdk-root>
is the place where your all android libraries and sdks were installed.
The script takes the mapping.txt file and your stack trace, producing a new, readable stack trace.
Command Syntax:
retrace.bat|retrace.sh [-verbose] mapping.txt [<stacktrace_file>]
For example:
retrace.bat -verbose mapping.txt obfuscated_trace.txt
I prefer local version of obfuscating as is quite handy to pre-check production errors.
I hope it helps.
Related videos on Youtube
CQM
Updated on July 22, 2022Comments
-
CQM almost 2 years
In Android Studio, where are the ProGuard mapping files generated after compiling a signed APK?
I'm not sure if it isn't working or if I just forgot the file path, and my compulsory Google/Stack Overflow search did not answer this
-
Jayakrishnan almost 7 yearsit is explained here officially firebase.google.com/docs/crash/…
-
CQM almost 7 years@JayakrishnanPM glad to see Google got around to it 3 years later.
-
-
aleb over 9 years'build/outputs/mapping/release/mapping.txt'
-
Boy about 9 yearsI found that printmapping was overruled by a template proguard file I was using!
-
Clive Jefferies about 9 yearsThis is better than my solution, as like you say you can then place it under version control.
-
Denny1989 almost 9 yearswhy would you like to version control this one? you need it for every APK you release seperately as it is build dependant. as you have to upload / checkin such an apk seperately from source there is actually no need to check it in the source VCS!?
-
Mark almost 9 years@Denny1989 not sure what you mean. I build an APK and store it outside version control. I have to keep the mapping file somewhere. I could store it alongside the APK, but I find it cleaner to version control it. However, I only have one release APK per project so YMMV.
-
j2emanue over 7 yearsthis worked and generated all the proguard output files for me.
-
Subho about 7 yearsYes that one is perfect for android studio 2.3.2
-
NukeouT over 6 yearsapp/build/outputs/mapping/release/mapping.txt bc there was a separate build folder that did not contain the mapping file...
-
Helton Isac about 6 yearsMore information about the generated files and path: developer.android.com/studio/build/shrink-code.html
-
Faizan Mubasher almost 5 yearsIf your Instant Run is enabled, you may not be able to see mapping file. Disable Instant Run and build again.
-
Carsten Hagemann about 4 yearsAfter an update to Gradle 6.2.2/Gradle Plugin 3.6.1 the paths changed for us.
/app/build/outputs/mapping/brandExampleEnvProductionRelease/mapping.txt
/app/build/outputs/mapping/brandExampleEnvIntegrationBeta/mapping.txt
are the new paths. -
Csaba Toth over 3 yearsStill no mapping directory. Maybe it's because V8 ignores progurad now? How to generate it with V8?
-
HX_unbanned over 3 yearsUPDATE: As of AS 4.1.1 , Gradle plugin 4.0.2 , Gradle 6.1.1 , you need to have
minifyEnabled true
to get mapping.txt inside thebuild/outputs/mapping/<FLAVOUR>/mapping.txt
-
Vikash Parajuli over 2 yearshow to add this path in bitrise.yml file?