How-To : Change the Package Name in Android Studio

While developing any Android application, generally it is the tendency of Android app developer to keep the PackageName as it is and not to change it. But at times, while uploading an application on Play store or due to some other constraints there could be a need to change the PackageName of Android application or some packages in the application.

Changing PackageName is a crucial part of any Android application as many of the core libraries and R.java file depends on the package name. Also, changing the package name was bit easy task for the Eclipse users, but this might not be the same in Android Studio as the package level names are not displayed in Eclipse style. i.e. In Eclipse, the packages are displayed with full parent hierarchy, but in Android Studio, it is displayed in a folder level hierarchy, so sometimes it looks bit difficult to change the PackageName.

So in this article, I have tried to share some important guidelines to make this process easier. This is already documented in the Android Studio guide which is so huge that most of the time it is difficult to read everything of it. The purpose of sharing this feature separately is to highlight the steps, so it is easy for all Android developers to quickly change the PackageName when needed.

Below are the steps for changing the PackageName in Android studio.

Lets say, I want to change package name com.mycompanyname1.data to com.mycompanyname.data.

Now again click on setting option and uncheck Hide Empty Middle Packages.

So now package name gets divided in different sub-package like com, com.mycompanyname1, com.mycompanyname1.data under java directory.

Right click on com.mycompanyname1 package name and click option Refactor->Rename option (Alt+Shift+R) then rename packagename dialog box opens up, just change the package name as you want. For current example, we changed mycompanyname1 to mycompanyname.

Android Team @ WeblineIndia

We have developed lots of Android apps for various domains like – Business, Social, Medical, News, Sports, Education, etc. We also have expertise in custom SDK development.

Following well defined standard development processes, coding standards, tools and techniques, it has always helped us to provide best mobile apps to our clients. Our main focus has always been to exceed client expectations and deliver easy to use technically strong apps. On the side, we also love contributing back to the community.