对于我们的命名约定,我们需要在apk名称的末尾添加文件的MD5。我试着利用这个乐趣
static def generateMD5(final file) {
MessageDigest digest = MessageDigest.getInstance("MD5")
file.withInputStream(){is->
byte[] buffer = new byte[8192]
int read = 0
while( (read = is.read(buffer)) > 0) {
digest.update(buffer, 0, read);
}
}
byte[] md5sum = digest.digest()
BigInteger bigInt = new BigInteger(1, md5sum)
return bigInt.toString(16).padLeft(32, '0')
在应用程序变量任务中
android.applicationVariants.all { variant ->
variant.outputs.all { output ->
output.outputFileName = "MyApp v${variant.versionName}-${generateMD5(output.outputFile)}.apk"
}
}
问题是APK文件不是在这个任务中创建的,所以我应该在哪里修改文件名?
发布于 2020-12-03 23:22:36
最后,我用jenkins和shell脚本完成了这项工作。谢谢!
https://stackoverflow.com/questions/63791658
复制相似问题