7

I build apk file with help of https://build.phonegap.com/apps/ portal evrey time I build debug or release apk file the names are:

______debug.apk or ______release.apk

I want to change the name of the release apk to something more significant, for example MyProject-v2.apk.

Any idea how can I change the name of the the apk file when it build?

Michael
  • 13,950
  • 57
  • 145
  • 288

8 Answers8

4

No, sadly you cannot control the file name in the config.xml, but the file name doesn't matter. In the config.xml, you specify the name of your app as it will appear to the users on their mobiles, and that's what matters.

If you like to give the file a specific name for your own file management (which is what I do too), you'll have to manually rename the file every time you create a new build.

Racil Hilan
  • 24,690
  • 13
  • 50
  • 55
2

The thing you should know is that APK names does not matter in its file name, What matters is what you said in the AndroidManifest.xml in the Application label:

 android:label="@string/app_name"

This is the only app name and it can even be different from package name so the apk being called ______debug.apk or ______release.apk doesnt matter it is just to differenciate if it is debug or release. You can just rename it just like any file in your computer even Michael.apk. And still all android phones will ignore the file names and go get the label at android:label="@string/app_name" so just copy the file and change it to anything you want and it works.

Xenolion
  • 12,035
  • 7
  • 33
  • 48
1

You can rename it as a file.

The installed apk name is same as what you defined in manifest.

Zoe
  • 27,060
  • 21
  • 118
  • 148
Saman
  • 211
  • 1
  • 2
  • 7
1

You can configure naming of you builds in gradle configuration

enter image description here

Scrobot
  • 1,911
  • 3
  • 19
  • 36
1

Add this to your android{} close in your module's build.gradle:

 // determine the apk file name when produced
applicationVariants.all { variant ->
    variant.outputs.each { output ->
        output.outputFile = new File(
                output.outputFile.parent,
                output.outputFile.name.replace("app", "YourAppNameHere-V${variant.versionName}"))
    }
}

the V is for the version number.

peresisUser
  • 1,680
  • 18
  • 23
  • Your answer is outdated. * What went wrong: A problem occurred configuring project ':app'. > groovy.lang.GroovyRuntimeException: Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated{apkData=Main{type=MAIN, fullName=debug, filters=[], versionCode=20102,. – Ako May 18 '20 at 02:27
1

Inside modules build.gradle file, add following line to android { defaultConfig { X } }

setProperty('archivesBaseName', "YourAppName-$versionCode")
Ako
  • 956
  • 1
  • 10
  • 13
1

In my case I just renamed the file app_release.apk to appname.apk and it works for me.

Same for app_debug.apk to appname_debug.apk

In project directory:

Example

While Installing

enter image description here

Nisha Jain
  • 637
  • 6
  • 14
0

You cannot control the file name in the config.xml. But if you have a self signed certificate and want to rename the apk, you can do it with zipalign:

zipalign.exe -v 4 platforms\android\app\build\outputs\apk\release\app-release-unsigned.apk platforms\android\app\build\outputs\apk\release\YouyAppName-v2.apk
Felipe Jacob
  • 384
  • 2
  • 9