Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the proguard mapping file name in gradle for Android project

I have android project based on gradle and I want to change mapping.txt file name after it's generated for my build. How can it be done?

upd

How it can be done in build.gradle? Since I have access there to my flavors and other stiff, I would like to create mapping file name based on flavor/build variant version.

like image 398
olegflo Avatar asked Mar 09 '15 17:03

olegflo


People also ask

Where is the ProGuard mapping file?

It is located in the <sdk-root>/tools/proguard/bin/ directory.

How do I add ProGuard to gradle?

To actually apply the plugin to your project, just add the line to your module level build. gradle(. kts) file after applying the Android Gradle plugin as shown below. ProGuard expects unobfuscated class files as input.


1 Answers

Simpler solution.

applicationVariants.all { variant ->         if (variant.getBuildType().isMinifyEnabled()) {             variant.assemble.doLast {                 copy {                     from variant.mappingFile                     into "${rootDir}/proguardTools"                     rename { String fileName ->                         "mapping-${variant.name}.txt"                     }                 }             }         }     } 
like image 81
igorepst Avatar answered Oct 11 '22 16:10

igorepst