Reputation: 4235
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.
Upvotes: 4
Views: 6755
Reputation: 1825
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
Upvotes: 5
Reputation: 3366
Apart from the usual java files and manifest that had to be renamed I had to also change the settings under Project Structure:
SO I went to File > Project Structure > Modules/app > Flavours
I then changed the Application ID and all worked great.
Hope this helps for other MAC users like myself. (Did not test on Windows)
Upvotes: 4