Where does Android Studio save the ProGuard mapping file?

AndroidAndroid StudioApkProguard

Android Problem Overview


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

Android Solutions


Solution 1 - Android

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 - Android

For me they are at 'build/outputs/mapping/release'

Solution 3 - Android

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 - Android

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 - Android

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.

Solution 6 - Android

enter image description here

Here it is in a picture - you will find it in the mapping folder:

Solution 7 - Android

I am using version Android Studio 2.2.2. For me it's located in the following locations:

For debug: \app\build\outputs\mapping\debug\mapping.txt

For release: \app\build\outputs\mapping\release\mapping.txt

Solution 8 - Android

If anyone is still searching for mapping.txt:

minifyEnabled in build.gradle has to be set to true

I'm using Android Studio 4.2 Beta 4 and the standard-setting was false.

If minifyEnable is set to false the build is not "minified", so a mapping-file is of course not necessary, but google-play-console asks for the mapping file anyway.

... Very confusing for a beginner

Solution 9 - Android

Because I'm dumb and get lost even when somebody tells me where the file is:

cd StudioProjects/fooProject
find . -name "mapping.txt" | xargs less

Solution 10 - Android

Proguard[About] outputs are located

<module_name>/build/outputs/mapping/<buildType>/
//e.g.
/Users/alex/Desktop/MyProject/MyModule/build/outputs/mapping/releasefree

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionCQMView Question on Stackoverflow
Solution 1 - AndroidScott BartaView Answer on Stackoverflow
Solution 2 - AndroidTomView Answer on Stackoverflow
Solution 3 - AndroidMarkView Answer on Stackoverflow
Solution 4 - AndroidClive JefferiesView Answer on Stackoverflow
Solution 5 - AndroidWitVaultView Answer on Stackoverflow
Solution 6 - AndroidSimonView Answer on Stackoverflow
Solution 7 - AndroidFaisal ShaikhView Answer on Stackoverflow
Solution 8 - Androidsascha4532View Answer on Stackoverflow
Solution 9 - AndroidphiloView Answer on Stackoverflow
Solution 10 - AndroidyoAlex5View Answer on Stackoverflow