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.