android 自定义打包,android 自定义打包后的app名称
使用自定義名稱打包 使用
applicationVariants.all { variant ->????//批量修改Apk名字
variant.outputs.all { output ->
if (!variant.buildType.isDebuggable()) {
//獲取簽名的名字 variant.signingConfig.name
//要被替換的源字符串
def sourceFile = "-${variant.flavorName}-${variant.buildType.name}"
//替換的字符串
def replaceFile = "_V${variant.versionName}_${variant.flavorName}_${variant.buildType.name}_${buildTime()}"
outputFileName = output.outputFile.name.replace(sourceFile, replaceFile);
//遺留問題:如何獲取當前module的name,如CodeBooke這個名字怎么獲取到
}
}
}
打包仍然出現
Error:(60, 0) Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated{apkData=Main{type=MAIN, fullName=xiaomiRelease, filters=[]}} of type com.android.build.gradle.internal.api.ApkVariantOutputImpl.
Open File
錯誤
查詢https://blog.csdn.net/uu00soldier/article/details/78440953
改為
android.applicationVariants.all { variant ->
variant.outputs.all {
outputFileName = "${variant.name}-${variant.versionName}.apk"
}
}
之后就沒有再報錯了
總結
以上是生活随笔為你收集整理的android 自定义打包,android 自定义打包后的app名称的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: c语言编程 新浪博客,[c语言编程]经典
- 下一篇: dnd 辅助 android,Easy