Android: How to change specific name of the generated apk file in Android Studio?

后端 未结 9 1690
遥遥无期
遥遥无期 2020-12-29 08:44

By default IDE genarate a apk like app-debug.apk or app-release.apk file but I need to generate specific name of the Apk of the Ap

9条回答
  •  被撕碎了的回忆
    2020-12-29 09:09

    Try this code:

    defaultConfig{
          applicationVariants.all { variant ->
                    changeAPKName(variant, defaultConfig)
                }
    }
    
    def changeAPKName(variant, defaultConfig) {
        variant.outputs.each { output ->
            if (output.zipAlign) {
                def file = output.outputFile
                output.packageApplication.outputFile = new File(file.parent, "Your APK NAME")
            }
            def file = output.packageApplication.outputFile
            output.packageApplication.outputFile = new File(file.parent, "Your APK NAME")
        }
    }
    

提交回复
热议问题