Reputation: 789
I want to change the package name of my Android project using Android Studio from let's say, com.company.myapp
to com.name.company.myapp
. While there are many questions and answers that deal with renaming a part of existing package name but I couldn't find any help on how to add a new part to it.
Please help me in this regard.
Thanks
Upvotes: 5
Views: 25819
Reputation: 101
Upvotes: 8
Reputation: 459
(which is now independent of the package name) can be done very easily in one step. You don't have to touch AndroidManifest. Instead do the following:
1. Right click on the root folder of your project.
2. Click "Open Module Setting".
3. Go to the Default tab.
4. Change the applicationID to whatever package name you want. Press OK.
P.S. if you're using google-services.json , make sure you update new ID there too.
Upvotes: 9
Reputation: 11
To Rename APP package:
AndroidManifest.xml
and build.gradle
file to the new package if you use this method.Note: it’s more safe to make a new project.
Upvotes: -2
Reputation: 93
I tried more than 10 approaches and none of them worked (and sometimes not explained completely, so I deviated a little and found my own way. Again, my way is also not simple, but it does the job and Google Play didn't give me any errors.
1. On the Project pane on the left, select Project (it might say Android).
2. Go to nameOfYourProject -> app ->src -> main ->java ->com -> example
3. Right click on "example" -> Refactor -> Rename and type your desired name, select the two check boxes and hit Refactor.
4. Now go one level above example (folder) and right click on "com", but this time DO NOT check the two check boxes (as it will also rename the "com.google...." parts of your project) and hit Refactor.
5. Now open your Manifist file and manually change the package to your desired name.
6. Rebuild your project. If you see any errors, just open the file with the error and change the package name manually.
7. Open your gradle.build file and change application ID, to your new package (only the parts of it, not everything) and hit Sync (top right side). Hopefully this works.
P.S. Another "easy way" might be to use Agent Ransack, search for the package name by enclosing it with quotations and manually change the package name. You might want to get a copy of your project before doing this. I didn't try it, cause I was already knee-deep with all the other methods here and didn't try.
Upvotes: 1
Reputation: 400
This answer from the link in the comment provided would be most likely to have any issues arise, and would be simple. Possibly tedious depending on your app. I attempted changing package name once and android studio does not accomplish this very well. Simple solution
Upvotes: 0