2

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.

Yanshof
  • 9,659
  • 21
  • 95
  • 195

2 Answers2

1

In `build.gradle' file:

defaultConfig {
        ...
        versionCode 4
        versionName "App name 1.x"
        project.ext.set("archivesBaseName", defaultConfig.versionName + "-" + defaultConfig.versionCode);
    }
anemomylos
  • 546
  • 1
  • 6
  • 14
1

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)
    }
}
Fatih Santalu
  • 4,641
  • 2
  • 17
  • 34