How do I add a version number to my APK files using 0.14+ versions of the Android Gradle plugin?

后端 未结 3 2045
不知归路
不知归路 2021-01-11 15:49

I want to have the versionName included in the name of the output APK files from my Android build.

There\'s an another answer that works with pre-0.14.x

3条回答
  •  时光说笑
    2021-01-11 16:15

    You need one more loop now that each variant can have multiple outputs:

    android {
        applicationVariants.all { variant ->
            variant.outputs.each { output ->
                output.outputFile = new File(
                        output.outputFile.parent,
                        output.outputFile.name.replace(".apk", "-${variant.versionName}.apk"))
            }
        }
    }
    

提交回复
热议问题