gradle 修改apk 名稱
阿新 • • 發佈:2019-01-09
- 修改library模組build 生成的aar包
apply plugin: 'com.android.library'
//修改release版本生成的aar的名字
libraryVariants.all { variant ->
variant.outputs.each { output ->
if (output.outputFile != null &&
output.outputFile.name.endsWith('.aar') &&
'release' .equals(variant.buildType.name)) {
def aarFile = new File(output.outputFile.getParent(),
"LeeSideslip.aar")
output.outputFile = aarFile
}
}
}
- 修改application build生成的apk名稱
apply plugin: 'com.android.application'
//修改release版本生成的apk的名字
applicationVariants.all { variant ->
variant.outputs.each { output ->
if (output.outputFile != null &&
output.outputFile.name.endsWith('.apk') &&
'release'.equals(variant.buildType.name)) {
def apkFile = new File(output.outputFile.getParent(),
"paytf${variant.versionName}.${variant.versionCode}_${variant.flavorName}.apk")
output.outputFile = apkFile
}
}
}