Android Studio modifies the name of the apk packaging and generation

Add in the android{} directory of the app's build.gradle file

android.applicationVariants.all { variant ->
    variant.outputs.each { output ->
        def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.apk')) {
            //这里修改apk文件名
def fileName = "指定的文件名.apk"
output.outputFile = new File(outputFile.parent, fileName)                                
        }
    }
}


For versions above gradle 3.0, use the following code to add

android.applicationVariants.all {
    variant ->
        variant. outputs .all {
             // Modify the apk file name
             here outputFileName = " ${variant. name } -v ${variant. versionName } .apk"
         }
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324683214&siteId=291194637