How to change the Package name in Android

SHISHIR
3 min readMay 27, 2020

--

The package name is a unique name to identify a specific app. It is very common we need to change the package name. Here i am going to show two ways to rename package in android app.

** Way 01 **

Step 01: 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

Step 02: 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

Important Note: When renaming com in Android Studio, it might give a warning. In such case, select Rename All

Step 03: 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:

Step 05: You may need to change the package= attribute in your manifest.

Step 06: Clean and Rebuild.

Step 07: Done! Anyway, Android Studio needs to make this process a little simpler.

** Way 02 **

Step 01: Go to your AndroidManifest.xml file, put your mouse cursor in front of the part of the package name you want to change.

Step 02: Right-Click > Refactor > Rename

Step 03: In the new window press Rename package

Step 04: Change name and press Refactor

Step 05: Press Do Refactor at the bottom.

Note: Usually package name is in format com.domain.appname, in this example we changed the appname part, but you can do the same steps for the domain too.

Done! You changed your package name! Be sure to give claps if you find this article helpful.

**New to Android? You should know what is AndroidX migration. Find details here AndroidX migration: what ,why, how?

**Want to make a super-high-quality, memory-efficient Android app? Then you should know about memory leaks. Find details from this article Memory Leaks in details in Android

--

--

SHISHIR

{ 'designation' : 'Lead Software Engineer' , 'hobby' : [ 'Music', 'Photography', 'Travelling' ] ,’email’: ‘shishirthedev@gmail.com’ }