Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Append version number into proguard mapping folder

I am able to auto rename my apk files in gradle.build using

setProperty("archivesBaseName", "MyAppName-$versionName")

Is there a similar method to automatically append the proguard mapping folder name with the version number?

Currently, the folder defaults to

...\app\build\outputs\mapping\release or debug

I am wondering if it is possible to create the mapping folders to something like release-1.0.1 or debug-1.0.1.

like image 832
Angel Koh Avatar asked Dec 21 '25 15:12

Angel Koh


2 Answers

Following¹ will rename mapping.txt to mapping-release-1.0.1.txt in the same folder.

In the module build.gradle file:

android {
    // lots of gradle code

    // The following portion renames the mapping.txt file.
    applicationVariants.all { variant ->
        if (variant.getBuildType().isMinifyEnabled()) {
            variant.assemble.doLast {
                variant.mappingFile.renameTo(file(
                    "${variant.mappingFile.parent}/mapping-${variant.name}-${variant.versionName}.txt"))
            }
        }
    }
}

You may also use variant.versionCode or other options in the file name.

Hope this helps.

like image 173
ozbek Avatar answered Dec 23 '25 04:12

ozbek


I guess you can write a method that do the renaming by copying the files to directories based on the current version. something similar to the answer here: How to change the proguard mapping file name in gradle for Android project

like image 41
Mina Wissa Avatar answered Dec 23 '25 04:12

Mina Wissa



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!