Skip to content Skip to sidebar Skip to footer

Android: How To Change Specific Name Of The Generated Apk File In Android Studio?

By default IDE genarate a apk like app-debug.apk or app-release.apk file but I need to generate specific name of the Apk of the App. For Example: My application name is iPlanter so

Solution 1:

Just add

archivesBaseName = "NAME_YOU_WANT"

in the android{} part of your gradle file.

You'll get "NAME_YOU_WANT-release.apk" as name of the generated file.

Solution 2:

Step 1: Go to root of the main project, under app , right click on app and refactor the app into specific name (example iPlanter) and press ok

Step 2: Go to Project Setting file which is setting.gradle file

setting.gradle file contains

include':app'

Now need to replace app by specific name.

For Example app replace by iPlanter in include ':app' it looks like below

include':iPlanter'

then Sync project, after that run your application. Finally, App generate an apk like iPlanter-debug.apk or iPlanter-release.apk file.

Solution 3:

You just have to add following one line of code in app level gradle.

  1. For name only

archivesBaseName = "NAME_YOU_WANT"

 defaultConfig {

       applicationId "com.PACKAGENAME"
       minSdkVersion Integer.parseInt(MIN_SDK_LIBRARY)
       targetSdkVersion Integer.parseInt(TARGET_SDK)
       versionCode 11
       versionName "2.3"
       multiDexEnabled true
       archivesBaseName = "NAME_YOU_WANT"
    }
  1. Name with version

archivesBaseName = "NAME_YOU_WANT" + versionName

defaultConfig {

   applicationId "com.PACKAGENAME"

   minSdkVersion Integer.parseInt(MIN_SDK_LIBRARY)

   targetSdkVersion Integer.parseInt(TARGET_SDK)

   versionCode 11

   versionName "2.3"

   multiDexEnabled true

   archivesBaseName = "NAME_YOU_WANT" + versionName
}

Solution 4:

You can use this for app name with current date and version

android {
defversion="2.4";
defmilestone="1";
defbuild="0";
defname= getDate()+"APP NAME WHAT YOU WANT"+"v"+version


signingConfigs {
    config {
       ….
   }
}
compileSdkVersion Integer.parseInt(COMPILE_SDK)
buildToolsVersion BUILD_TOOLS_VERSION
defaultConfig {
   applicationId "com.PACKAGENAME"
   minSdkVersion Integer.parseInt(MIN_SDK_LIBRARY)
   targetSdkVersion Integer.parseInt(TARGET_SDK)
   versionCode 11
   versionName "2.3"
   multiDexEnabled true
}
buildTypes {
   debug {
       applicationVariants.all { variant ->
           variant.outputs.each { output ->
               defapk= output.outputFile;
               def newName;
               newName = apk.name.replace("-" + variant.buildType.name, "")
                       .replace(project.name, name);
               newName = newName.replace("-", "-" + version + "-" + milestone +
                       "-" + build + "-");
               output.outputFile = newFile(apk.parentFile, newName);
           }
       }
   }

Solution 5:

For Android Studio 3, this works for me:

applicationVariants.all { variant ->
        variant.outputs.all { output ->
            outputFileName = newFile("AppName-" + variant.versionName + ".apk");
        }
}

Post a Comment for "Android: How To Change Specific Name Of The Generated Apk File In Android Studio?"