Android Studio设置apk文件名
16lz
2021-01-23
Android Studio 2.x
applicationVariants.all { variant -> variant.outputs.each { output -> def outputFile = output.outputFile if (outputFile != null && outputFile.name.endsWith('.apk')) { // 这里修改apk名称 def fileName = "hello_${defaultConfig.versionName}.apk" output.outputFile = new File(outputFile.parent, fileName) } }}
使用AS3时这样设置会遇到错误:Cannot set the value of read-only property ‘outputFile’
Android Studio 3
android.applicationVariants.all { variant -> variant.outputs.all { outputFileName = "hello_${defaultConfig.versionName}.apk" }}
参考:https://stackoverflow.com/questions/44239235/android-gradle-3-0-0-alpha2-plugin-cannot-set-the-value-of-read-only-property
更多相关文章
- android 开发中遇到错误及解决办法总结(在别处看到的)
- Android 'showAsAction' in package 'android'错误解决
- Android Studio 提示错误:No IDEA annotations attached to the J
- Android 错误 'roundIcon' in package 'android'
- 错误:AGPBI: {“kind“:“error“,“text“:“Android resource c
- xarmain使用Forms编译android工程出现support_r19.0.1.zip支持包
- Android Studio 错误 Duplicate files copied in APK META-INF/L
- 升级android sdk时A folder failed to be renamed or moved 错误