• Home
  • Uncategorized
  • Compile an Android application with a different Application Name and Package Name

Compile an Android application with a different Application Name and Package Name

This was tested on Android Studio and with the source code for Telegram.

To change the package name for your build, an easy way would be to add a flavor of the app:


Under the section android {, add the following:

productFlavors {
        securechat {
            packageName "com.joel.telmsg"
            versionCode 20


This will take care of changing your package name so that you can install a second version of th same application.

Next, we will take care of the Application name shown in the icon menu:

In the tag, add the following:


, so that the final code looks like this:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"

Now, in


tag, add the following:


to replace the existing android:label text.

To change the name of the output .apk file, add the following:

applicationVariants.all { variant ->

        def apk = variant.outputFile;
        def newName;

        newName = apk.name.replace(".apk", "-v" + defaultConfig.versionName + "-" + variant.buildType.name.toUpperCase() + ".apk");

        newName = newName
                .replace("-" + variant.buildType.name, "")
                .replace(project.name, "droidzone");

        variant.outputFile = new File(apk.parentFile, newName);
        if (variant.zipAlign) {
            variant.outputFile = new File(apk.parentFile, newName.replace("-unaligned", ""));

        logger.info('INFO: Set outputFile to ' + variant.outputFile + " for [" + variant.name + "]");

to Telegram/TMessagesProj/build.gradle