How to rename package name in android studio

Package name is an important part of an android application. Android applications are identified in play store by its unique package name. So deciding a unique package name is an important factor while developing an android application. But what if the developer gave a random package name at the development stage and you need to change name later at the time of releasing application?

By renaming the package name directly will create lot of issues. In this tutorial we will learn how to rename the package name in android studio in most cleanest way.

If you find this tutorial usefull please subscribe to our youtube channel


  1. Break package view into individual directory view
  2. Renaming individual directory name
  3. How to rename com directory
  4. Change application id in build.gradle
  5. Rename package name in android manifest

1.Break package view into individual directory view

First step of changing the package name in android is to change the package view in android studio into individual directory view. For doing that click on the gear icon on the project panel on left side and uncheck Compact Empty Middle Packages .

Once you unchecked the Compact Empty Middle Packages you can see your package as individual folders under your java folder.

2.How to rename the individual directory name

Once we have individual folder view of package we can rename the individual directory .For renaming the individual directory just right click on the directory ,one list will appear and click on the Refactor and then a sub list will appear, in the sub list click on Rename

After clicking on rename as mentioned in the above image a popup will appear which will show a warning with some action buttons. There will be three buttons ,among that click on Rename package button. And suppose if you want to cancel the refactor just click on cancel button.

Now after clicking on Rename package button as in the above image this existing popup will dismiss and another popup will appear which will contain the existing directory name. Now we can replace the existing name with the new directory name and hit enter or refactor button.Android studio will display all the list of files where the above directory name is used. It will ask a confirmation with a Do Refactor and cancel buttons like in the following image. So for completing the change directory process just click on the Do Refactor button.

Now just wait for sometime you can see that the folder name is changed on the left panel.

3.How to rename com directory

Now we know how to rename the individual directories. But incase if you want to rename the com directory it is a different case. You just need to follow the same steps itself ,but android studio will show a warning popup with another three buttons named Rename current, Rename all and cancel button. You should click on Rename all button as in the following image.

4.Change application id in build.gradle

After changing all the directory name we need to set up our gradle file with new package name. Once you open the build.gradle file you can see your previous package name in the code as applicationId . You can replace the package name with new package name and click on Sync.

5.Rename package name in AndroidManifest.xml

Now we need to replace the package name in AndroidManifest.xml if it didn’t change automatically after gradle sync. And if you where using the complete package name in individual activity tag you may need to change that as well.You can replace the all string with new package name together by pressing cntrl + R and provide the string to be found and replace package name in a single click activity . After completing the step just rebuild the project, your package name rename process is completed.

About the author

Hi guys, i am the author of codesfor. I am a B.Tech graduate currently working as an App developer. Apart from job i am a blogger and a freelancer.

Add a Comment

Your email address will not be published. Required fields are marked *