Fully change package name including company domain
In Android Studio, you can do like this:
For example, if you want to change com.example.app to iu.awesome.game, then:
- In your Project pane, click on the little gear icon ( )
- Uncheck / De-select the Compact Empty Middle Packages option
- Your package directory will now be broken up in individual directories
Individually select each directory you want to rename, and:
- Right-click it
Select Refactor
Click on Rename
In the Pop-up dialog, click on Rename Package instead of Rename Directory
Enter the new name and hit Refactor
Click Do Refactor in the bottom
Allow a minute to let Android Studio update all changes
Note: When renaming com in Android Studio, it might give a warning. In such case, select Rename All
Now open your Gradle Build File (build.gradle - Usually app or mobile). Update the applicationId in the defaultConfig to your new Package Name and Sync Gradle, if it hasn't already been updated automatically:
You may need to change the package= attribute in your manifest.
Clean and Rebuild.
Done! Anyway, Android Studio needs to make this process a little simpler.
This worked for me, from https://stackoverflow.com/a/18637004/127434
Another good method is: First create a new package with the desired name by right clicking on the java folder -> new -> package.
Then, select and drag all your classes to the new package. AndroidStudio will refactor the package name everywhere.
Finally, delete the old package.
current package : com.company.name
New package : com.mycomapny.name
Steps: 1) Suppose you are at this screen which is shown below.
2) Open project pane and click on settings icon.
3) Deselect Compact Empty Middle Packages.
4) Then your package is now broken into individual parts as shown below .
5) right click on "company" select Refactor -> select rename ->rename directory.
6) Now your "company" has been changed to new "mycomapny" and changes were reflected as shown in below figure.
7) Now change the package name in AndroidManifest.xml file .
8) Open app level build.gradle and change package name .
9) you will get errors as Cannot resolve symbol "R" .
10) Remove line which gives this error and studio will import new R file automatically.
11) If you have multiple files then use find and replace option by pressing " Cntrl+Shift+R "
Or " Select Edit->Find->Replace in path.."
12) select Replace All.
You can do this:
Change the package name manually in the manifest file. Click on your R.java class and the press F6 (Refactor->Move...). It will allow you to move the class to other package, and all references to that class will be updated.
reference: How do I rename the android package name?