How to Rename Package in Android Studio

Many new developers will find it hard to rename a package. By default, package names are compacted in Android Studio, and that’s the reason why many can’t find a way to rename it.

Step to refactor package renaming

1) Disable name compact mode

On the Project tab, click on the Gear icon to open a new menu then uncheck “Compact Empty Middle Packages” menu item.

Now all packages will be listed in hierarchy.

2) Refactor name

Right-click on the package you want to rename, select Refactor then Rename (You can use Shift + F6 shortcut to quickly access name refactor).

When a new popup menu appears, choose Rename Package then click on Refactor button.

3) Change package name in build.gradle

If Android Studio notifies error in buld.grable, open it and change the package name to new one.

Leave a Comment

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

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.