My android application company domain is something like com.example.android.myfirstapp
. When publishing to this to play store we need to give a unique id form my app. So how can I change this package name to something like com.MyUniqueCompName.MyUniqueApp
?
I saw some links to change the last block. But I want to change the middle one and reduce the package names. And also if I change the package name by refactoring, it is importing the old package to java files. Is it ok? Is there any way to change the package of R.class
?
Asked
Active
Viewed 2,176 times
1
-
Related posts - [Rename package in Android Studio](https://stackoverflow.com/q/16804093/465053) & [Fully change package name including company domain](https://stackoverflow.com/q/18558077/465053) – RBT Dec 19 '19 at 23:46
4 Answers
0
You can create a new Package, and drag all your file in the new one. Android Studio will refactor the code for you.
Then you need to change it in your build.gradle(module:app).

Manfredi
- 172
- 1
- 12
-
I tried this way. But it is importing old package in all java classes. I think this is because R.java package is not changed. Is it ok? I mean how do we remove all the references of old package? – Creative Jul 23 '15 at 09:01
-
Right click on the java folder > create a new Package > give it the name that you want. Then select all your class, drag them to the new Package and a new window will open. Click "Refactor" and Android Studio will take care of the rest. – Manfredi Jul 23 '15 at 09:59
0
In your build.gradle file there is
applicationId "aaa.bbb.ccc"
You can change that to whatever you want. Or, if it does not exist you can add it. There's no need to rename the java packages this way.

Alexander Kulyakhtin
- 47,782
- 38
- 107
- 158
0
It's enugh to change your appId from gradle:
applicationId "com.domain.yourcompany"

savepopulation
- 11,736
- 4
- 55
- 80
0
right click on java folder, create new packages with desired name, and one Androidtest package then drag drop folders in new packages (old will automatically delete) rename package name in: manifest file build.gradle and in any activity or file where command import package.R exists build and done!

G. Lemonakis
- 1
- 1