Gradle warning: variant.getOutputFile() and variant.setOutputFile() are deprecated

后端 未结 4 1278
栀梦
栀梦 2020-12-01 05:56

I am using the following simplified configuration in an Android application project.

android {
    compileSdkVersi         


        
4条回答
  •  萌比男神i
    2020-12-01 06:43

    Building on the answer from Larry Schiefer you can change the script to something like this:

    android {
        applicationVariants.all { variant ->
            variant.outputs.each { output ->
                def outputFile = output.outputFile
                if (outputFile != null && outputFile.name.endsWith('.apk')) {
                    def fileName = outputFile.name.replace('.apk', "-${versionName}.apk")
                    output.outputFile = new File(outputFile.parent, fileName)
                }
            }
        }
    }
    

提交回复
热议问题