Android IDE

How To Change Package Name In Android Studio

Have you ever encountered the headache of changing the package name and leaving it with some undesired name? if so through this article i can convince you that this is the one of the simplest task to do and it will take less than 1 minute if you are using Android Studio IDE.

When thinking about changing the name many thoughts may came to our mind one of them about changing the package name on each line of source code files.

When Android Studio introduced Refactor tool renaming becomes smooth and leaving this headache to the Refactor Tool. With this tool we are able to make changes to packages at any point. Thanks to Refactor Tool.

Package name should be unique so it is the vital part of making Android Application unique. Android Operating system identifies each application by this package name. Most developers are adding their branding information to the package name for quick identification and authorization.

Packages are just directories where we add java files of similar functionalities. If you rename folders through operating systems then your code will not reflect these changes. If the change should be synced with Android Studio then it must be done through Refactor Tool.

Please read this article. This is a task of 2-3 steps. But for the understandability i have expanded this steps with screenshots.

Mainly 4 places where you can find package name specified.

  • AndroidManifest.xml file
  • Build.gradle file – requires manual edit
  • Java source code
  • Name of the Directory

if you change package name in project then the change should reflect in these 4 places. After changing the package name using the following steps you should make sure that the changes are also applied to these places.

Here in this tutorial i am going to change the package name of the project from to

Step 1: Switch View To Compact Empty Middle Packages


This action will split your packages into sub packages.

Step 2: Rename Package Using Refactor Tool

Right Click on project explorer menu and you can see Compact Empty Middle Packages. Select this option. After selection the explorer menu will be changed and all the packages are now separated for individual refactor. Refactor tool will change the name of package in source code files.


Now you can refactor desired package as you do in the code. For that right click on the package where you can see Refactor option when you select it again opens up a sub options. Please select Rename. Click on it.


If you are asked for confirmation for renaming then please click Rename Package button.


This dialog box is for editing the existing package name. Here my existing package name is myapplication.


I am changing package name to new name called yourapplication.


This is asking for final confirmation to proceed. Because Android Studio has found the usage of old package name used in some places in the project. So the IDE will preview the refactoring code lines. If you press Do Refactor then it will apply the changes to these places.

After all these above steps are done please make sure that the changes are applied to the above mentioned 4 places.
Good luck!

About author

Rojer is a programmer by profession, but he likes to research new things and is also interested in writing. Devdeeds is his blog, where he writes all the blog posts related to technology, gadgets, mobile apps, games, and related content.

Leave a Reply

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