So to change the generated APK filename inside gradle android I could do something like:
applicationVariants.output.all {
outputFileName = \"the_file_nam
Solution from @SaXXuM works great! Task is not necessary for renaming artifact. You can call setProperty()
directly in the android {}
block. I prefer to have in the file name:
This is how I use it in my projects:
build.gradle:
apply from: "../utils.gradle"
android {
...
setProperty("archivesBaseName", getArtifactName(defaultConfig))
}
utils.gradle:
ext.getArtifactName = {
defaultConfig ->
def date = new Date().format("yyyyMMdd")
return defaultConfig.applicationId + "-" + project.name + "-" + defaultConfig.versionName + "-" + defaultConfig.versionCode + "-" + date
}
The result is: com.example-app-1.2.0-10200000-20191206-release.aab
It works for both - APK and AAB.