For android developer package name is very important, because its the identifier for their application. Rename package on android studio is no longer difficult. But here we provide brief step to rename package :
New package : com.new.package
Old package : com.old.package
Make sure there’s no app use same package by checking here https://play.google.com/store/apps/details?id=[your new package] like this : https://play.google.com/store/apps/details?id=com.new.package
If your purpose renaming package is for google play upload, on Android Studio you only need to change applicationId at app/build.gradle
Then you no need to do instruction below because some case face error,
- Create new package in java directory, e.g. “com.new.package“. Right click on app/src/main/java directory -> New -> Package.
- Select all packages and classes in “com.old.package” and move (drag) them to the new package. Confirm by click on “Do Refactor“.
- Delete the old package “com.old.package“.
- Open app/src/main/AndroidManifest.xml and rename the package name by selecting text package name “com.old.package” -> Right click on selected text -> Refactor -> Rename -> enter the new package name, select “Search in comments and strings” option -> Refactor -> Do Refactor.
- Clean the project. Main menu -> Build -> Clean Project.
- Replace all occurrences of “com.old.package” for a new package name, e.g. “com.new.package“. Right click on app directory -> Replace in Path -> set old and new package names, Case sensitive to true -> Find -> Replace.
- Clean the project again. Main menu -> Build -> Clean Project.
- Synchronize the project. Main menu -> Tools -> Android -> Sync Project with Gradle Files.
- If you see “Activity class does not exist” error, restart Android Studio.
Hope this help 🙂