Change Package Name Android Studio

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

capture

Then you no need to do instruction below because some case face error,

  1. Create new package in java directory, e.g. “com.new.package“. Right click on app/src/main/java directory -> New -> Package.
  2. Select all packages and classes in “com.old.package” and move (drag) them to the new package. Confirm by click on “Do Refactor“.
  3. Delete the old package “com.old.package“.
  4. 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.
  5. Clean the project. Main menu -> Build -> Clean Project.
  6. 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.
  7. Clean the project again. Main menu -> Build -> Clean Project.
  8. Synchronize the project. Main menu -> Tools -> Android -> Sync Project with Gradle Files.
  9. If you see “Activity class does not exist” error, restart Android Studio.

Hope this help 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *