- Android Phones
Android - How to rename an app package name
Your app on Android Studio
Android Studio is the official Integrated Development Environment (IDE) to build Android apps, it's based on IntelliJ IDEA and offers even more features that enhance your productivity when building Android apps.
Either you created a new app or are editing an existing one, Android projects have their own package name which is an identifier of such project. It usually is made by reverse domain name, something like com.domain.appname.
You can find this string into the Manifest.xml file, build.gradle and on the top of all .java files. Keep reading to see how to rename a package name.
The Project panel
On the right side of the Android Studio's window you can see the Project panel, wher all the files of your app are displayed as a hierarchy.
In case you don't see it, click on the top-left button and select Android option (it has also the Android green robot icon next to it).
So now, follow these steps to rename the package:
1. In your Project panel, click on the little gear icon, as shown in the image below.
2. Uncheck/deselect the Compact Empty Middle Packages option.
Your package directory will now be broken up in individual directories
3. 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
- Allow a minute to let Android Studio update all changes
NOTE: When renaming com in Android Studio, it might give a warning. In such case, select Rename All
4. Now open your build.gradle file and rename the applicationId into your new package name, then click on Sync Gradle on the top-right corner, usually it's highlighted by a yellow bar.
5. Wait for the Gradle synch to be done.
6. Select another folder of your package name you want to rename, and just repeat the steps above.
7. Great job, you're done!
Thanks for reading, don't forget to check out my other tutorials and my portfolio on CodeCanyon as well!
© 2017 cubycode