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" } }