Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio - Change applicationId in build.gradle file

How can I change the applicationId field of my build.gradle file?

defaultConfig {
    applicationId "com.oldname.appname"
    minSdkVersion 15
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
}

I've already renamed the package structure to com.newname.appname and all the imports and things like that have updated, but applicationId hasn't. I can't refactor it and just trying to type in a new name brings up a ton of errors where Android Studio will tell me my main FragmantActivity "is not applicable to android.app.Activity" and so on.

Any idea what to do? Thanks in advance.

like image 813
pez Avatar asked Jan 08 '23 13:01

pez


1 Answers

You can create different flavours for one application in Gradle file. This will increase the code reusability.

An example for an application with Paid and Free flavors:

productFlavors {

    paid {
        applicationId "com.oldname.appname.paid"
    }

    free {
        applicationId "com.oldname.appname.free"
    }

}

So these two flavours will act as two products. You can upload it to play store as different applications.

You can also get four build variant for this two flavours.

com.oldname.appname.free- debug

com.oldname.appname.free- release

com.oldname.appname.paid- debug

com.oldname.appname.paid- release

like image 181
Nithinjith Avatar answered Jan 31 '23 20:01

Nithinjith