3

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.

ozbek
  • 20,955
  • 5
  • 61
  • 84
Angel Koh
  • 12,479
  • 7
  • 64
  • 91
  • 2
    I got to know that we can change the apk name programatically by your question .Thanks :) – nishith kumar Dec 21 '16 at 12:02
  • if you can it will be written somewhere in the docs here: https://www.guardsquare.com/en/proguard/manual/usage#obfuscationoptions – Blundell Dec 30 '16 at 09:06

2 Answers2

2

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

Community
  • 1
  • 1
Mina Wissa
  • 10,923
  • 13
  • 90
  • 158
2

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.

ozbek
  • 20,955
  • 5
  • 61
  • 84