Change package names in Android Studio

I’ve recently had to change the package name of the app that I was working on for a client twice. I noticed that this isn’t exactly intuitive to do in Android Studio, so this will be a short little guide to doing that.

As a preface, I’m running Android Studio 2.2.3. Whether you’re an older version of Android Studio or newer version if you’re reading this from the future, I’m pretty sure the interface would be relatively similar.

Anyways, let’s say that this is the app I’m working with where the package name is “com.toasterbits.customsearchviewrecipe” and I want to change the package name to “”. First thing we should do is open up AndroidManifest.xml file and change the package field in the manifest bracket from “com.toasterbits.customsearchviewrecipe” to “”.

After you do that, open up your app’s “build.gradle” file and change the applicationId in the defaultConfig bracket to the new package name

After we do this, we are now ready to change the actual package names themselves.

In Android Studio, click that little wheel looking bar button in your Projects panel.

There, uncheck/deselect the setting “Compact Empty Middle Packages”. Once you do that, your package names in your Projects panel will be broken up from “com.toasterbits.customsearchviewrecipe” to something like “com” -> “toasterbits” -> “customsearchviewrecipe”. It’ll look something like this

From here, right click on the portion of the package name you want to modify. In my case, it’ll be both “toasterbits” and “customsearchviewrecipe”. Once you right click, go to “Rename” and then “Refactor”. Choose your new package name and choose “Rename Package” instead of “Rename Directory”.

Do this until you get the package name you want.

After that, resync your project from build.gradle file, clean your project, and then rebuild your project.

And voila! You have just changed the package name of you Android app.

About the Author Chris Jeon

Software developer currently focusing on Android development.