There are some cases when you develop Android application, you need to change your package name. Whether request from your client or your own projects, or there are the same package name in Play Store with your app package name. This package name need to be unique if you want to upload to Play Store. Some people still struggle to change the existing package name, including me. Haha 🙂
After doing some research, this guide is the best solution and easy to follow guide for everyone. I will guide you step by step how to change Android package name in Android Studio. Let’s begin.
First, in this tutorial, let’s say we have package name
com.example.sampleapp and we want to change it to
Step 1 Unchecked Compact Middle Packages
The default setting of Android Studio that it has
Compact Middle Packages checked. So you need to unchecked it. Go to Android Studio project explorer -> Navigate to gear icon (as picture below) -> Uncheck Compact Media Packages
This option will de-compact your package name so you can easily change the package name later. Notice the project structure change to individual folder.
Step 2 Rename each package subfolder
We want to change our package name from
com.waysquare.firstapp. So, we need to change the second and third subfolder name.
Right click on
example folder and choose Refactor -> Rename
If this popup appear choose Rename package to continue.
Checked also the two checkbox to apply changes to comments and strings.
Confirm your change by clicking Do Refactor button.
You are done by changing the second subfolder. Do the same for third subfolder from
Now your project structure will appear like below.
Step 3 Replace All Package Name in Code
Next step is to change all the package name shown in our code to our new package name.
Right click on
app folder and choose Replace in Path…
Replace package name before and after. If no any available package name to change, the window will show Noting to show message. Confirm by clicking Open in Find Window.
If new dialog box “Do you want to replace this occurnace?” appear, confirm it by clicking “All Files” button.
You are finish. Try to clean your project and rebuild. Check if any error occur.
Originally posted 2019-09-11 00:20:33.
- rename package name in android studio 2022