Android genera automáticamente el nombre del archivo apk con el número de versión y el tipo de lanzamiento

Agregue el siguiente código en app.gradle

Puede modificarse según sus necesidades

afterEvaluate {
    android.applicationVariants.all { variants ->
        if (variants.getName().endsWith("Release") || variants.getName().endsWith("release")) {
            variants.outputs.all { output ->
                if (output.outputFile != null &&
                        output.outputFile.name.endsWith('.apk')) {
                    output.outputFileName = "${variants.flavorName}_${variants.versionName.replace(".", "_")}.apk"
                }
            }
        } else if (variants.getName().endsWith("Debug") || variants.getName().endsWith("debug")) {
            variants.outputs.all { output ->
                if (output.outputFile != null &&
                        output.outputFile.name.endsWith('.apk')) {
                    output.outputFileName = "${variants.flavorName}_${variants.versionName.replace(".", "_")}_debug.apk"
                }
            }
        }
    }
}

Supongo que te gusta

Origin blog.csdn.net/qq_36355271/article/details/99844799
Recomendado
Clasificación