Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing only Application ID, not package name

I only want to change application id in gradle file, but dont want to change package name.
Is it possible?

like image 944
Bahadır Civelek Avatar asked Sep 06 '17 18:09

Bahadır Civelek


People also ask

Is application ID the same as package name?

The applicationId exactly matches the Java-style package name you chose during project setup in android studio. However, the application ID and package name are independent of each other beyond this point.

How do I change my application ID?

Select Android on the top left of the Project window. So, right click over your package name under Java folder and select "Refactor" -> Rename... Click in Rename Package Button. Type the name of the new package you want, mark all options then confirm.


1 Answers

It is not recommended to change your application id. What you can do is change your application suffix.

As an example, if your application id is com.example.my_app then add different suffixes for different build types, such as com.example.myapp.dev for debug.

Go to app/build.gradle file and on android block add the suffix you want:

buildTypes {
        release {
            applicationIdSuffix ".production"
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
            applicationIdSuffix ".dev"
            versionNameSuffix '-DEBUG'
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

Read more about it here

like image 98
João Magalhães Avatar answered Sep 25 '22 18:09

João Magalhães