I'm trying to use 'generate signed APK' to create release apk on android studio.
Android studio create apk with name 'app-release.apk'
I want to set my name to this apk and i don't find any way to do it.
I'm trying to use 'generate signed APK' to create release apk on android studio.
Android studio create apk with name 'app-release.apk'
I want to set my name to this apk and i don't find any way to do it.
In `build.gradle' file:
defaultConfig {
...
versionCode 4
versionName "App name 1.x"
project.ext.set("archivesBaseName", defaultConfig.versionName + "-" + defaultConfig.versionCode);
}
One way to that
setProperty("archivesBaseName", "apk_name")
and another way is
applicationVariants.all { variant ->
variant.outputs.each { output ->
project.ext { appName = 'MyAppName' }
def formattedDate = new Date().format('yyyyMMddHHmmss')
def newName = output.outputFile.name
newName = newName.replace("app-", "$project.ext.appName-")
newName = newName.replace("-release", "-release" + formattedDate)
output.outputFile = new File(output.outputFile.parent, newName)
}
}