Android ProGuard multiple files mapping for split APKs?

I am successfully generating signed APKs in android studio, breaking them down into ABIs and assigning versions to each other by adding the following code to my file build.gradle

:

// Map for the version code that gives each ABI a value.
ext.abiCodes = ["armeabi-v7a":1, "arm64-v8a":2, "x86":3, "x86_64":4]

import com.android.build.OutputFile

// For each APK output variant, override versionCode with a combination of
// ext.abiCodes + variant.versionCode. In this example, variant.versionCode
// is equal to defaultConfig.versionCode. If you configure product flavors that
// define their own versionCode, variant.versionCode uses that value instead.
android.applicationVariants.all { variant ->

    // Assigns a different version code for each output APK
    // other than the universal APK.
    variant.outputs.each { output ->
        // Stores the value of ext.abiCodes that is associated with the ABI for this variant.
        def baseAbiVersionCode =
                // Determines the ABI for this variant and returns the mapped value.
                project.ext.abiCodes.get(output.getFilter(OutputFile.ABI))

        // Because abiCodes.get() returns null for ABIs that are not mapped by ext.abiCodes,
        // the following code does not override the version code for universal APKs.
        // However, because we want universal APKs to have the lowest version code,
        // this outcome is desirable.
        if (baseAbiVersionCode != null) {

            // Assigns the new version code to versionCodeOverride, which changes the version code
            // for only the output APK, not for the variant itself. Skipping this step simply
            // causes Gradle to use the value of variant.versionCode for the APK.
            output.versionCodeOverride =
                    baseAbiVersionCode + variant.versionCode
        }
    }
}

      

Now I want to use ProGuard ( minifyEnabled true

) to obfuscate my code. As stated in the official Android documentation , it is important to save the files mapping.txt

for every APK you release in order to decrypt the crash report of the convoluted stack trace obtained through the Google Play developer console. But when I generate an ABI split APK, I only find one file mapping.txt

in the directory <module-name>/build/outputs/mapping/release/

.

My question is: . Can anyone confirm that this single file mapping.txt

allows me to decode trace stack obfuscation for 4 APKs that have been split by ABI? If not, how can I generate 4 different mapping files?

I tried to create different mapping files based on the snippet I found in this post essentially trying to copy and rename the files mapping.txt

as they are generated during the multiple APK generation process, but I still only get one mapping file:

applicationVariants.all { variant ->
    if (variant.getBuildType().isMinifyEnabled()) {
        variant.assemble.doLast {
            copy {
                from variant.mappingFile
                into "${rootDir}/proguardTools"
                rename { String fileName ->
                    "mapping-${variant.name}.txt"
                }
            }
        }
    }
}

      

I am very new to gradle and I find its syntax rather confusing. Any help would be much appreciated.

+3


source to share


1 answer


I ended up testing stack trace deobfuscation with Firebase Crash Reporting (i.e. without having to deploy a test version of my app to the google play store) and I can confirm that one mapping.txt

file generated when generating signed APKs in Android Studio will correctly deobfuse stack traces for crashes occurring on APKs corresponding to different ABI types.



0


source







All Articles