Android Studio 配置输出apk的名字
16lz
2021-01-23
1、在项目app下的build.gradle中的android标签中做如下配置:
android.applicationVariants.all { variant ->
variant.outputs.each { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.apk')) {
// 这里修改apk名称
def fileName = outputFile.name.replace("app", "xxoo_${defaultConfig.versionName}.${defaultConfig.versionCode}_${releaseTime()}")
output.outputFile = new File(outputFile.parent, fileName)
}
}
}
2、在项目app下的build.gradle中的android标签中做如下配置,如果碰到以下错误:
Cannot set the value of read-only property 'outputFile’….
参考文章: Android Gradle 3.0.0-alpha2 plugin, Cannot set the value of read-only property 'outputFile'
请尝试下边的操作方式:
android.applicationVariants.all { variant ->
variant.outputs.all { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.apk')) {
// 这里修改apk名称
def fileName = outputFile.name.replace("app", "xxoo_${defaultConfig.versionName}.${defaultConfig.versionCode}_${releaseTime()}")
outputFileName = new File(outputFile.parent, fileName)
}
}
}
更多相关文章
- Windows下,Android Studio项目路径中包含中文字符无法编译的问题
- android studio 3.0配置自定义打包名称
- Google code android开源项目(二)
- android项目中的功能清单文件
- android 开源项目介绍
- Android输入框格式化Edittexthelp(有项目可下载)
- android 命令获取手机中项目数据库
- android项目,从服务器端返回JSON数据,在android客户端进行显示。
- Android利用资源名称获取其id之getIdentifier()方法