For our naming convention, we need to add in the end of the apk name the MD5 of the file. I tried to use this fun
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')
and in the application variant task
android.applicationVariants.all { variant ->
variant.outputs.all { output ->
output.outputFileName = "MyApp v${variant.versionName}-${generateMD5(output.outputFile)}.apk"
}
}
The problem is that the APK file is not created in this task, so where i should modify the filename?