How to rename a package in Android Studio?
Here I will show you how to rename the package name in Android Studio. For example: there is a package with name "ru.ifsoft.network" and we need to rename it to "ua.mycompany.android"
1.) Open the project in Android studio.
2.) Click -> package name (1), click -> gear icon (2), click -> menu item "Hide Empty Middle Packages" (3)
How to rename a package in Android Studio
3.) After the previous step, the package name will be expanded. See screenshot:
How to rename a package in Android Studio
4.) Select desired item from the package name and press Shift + F6 (1), Enter a new name for selected item from package name (2), and click "Refactor" (3)
How to rename a package in Android Studio
5.) Click -> Do Refactor
How to rename a package in Android Studio
6.) We are looking at the result. Hooray! Part of the name is renamed!
How to rename a package in Android Studio
7.) Repeat steps 4,5 and 6 for parts of package name "ifsoft" and "ru"
8.) Click on part of package name "ua" (1), click gear icon (2) and click menu item "Compact Empty Middle Packages" (3)
How to rename a package in Android Studio
9.) In build.gradle file, also need rename package name (applicationId)
How to rename a package in Android Studio
10.) Renaming package name is completed!
11.) After renaming the package, you need to get a new "google-services.json" (configure FCM for the new package) or you will get an error! How to get the new "google-services.json" you can see here How to create FCM project? and here How to add new project to you current FCM project?