Rename package Android Studio

Here step rename package project In Android Studio, in example


from : com.old.app.package
to : com.new.app.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.app.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.app.package. Right click on app/src/main/java directory -> New -> Package.
  2. Select all packages and classes in com.old.app.package and move (drag) them to the new package. Confirm by click on Do Refactor.
  3. Delete the old package com.old.app.package.
  4. Open app/src/main/AndroidManifest.xml and rename the package name. Select package name com.old.app.package -> Right click on selected text -> Refactor -> Rename -> enter the new package name (com.new.app.package),  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.app.package for a new package name, e.g. com.new.app.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 appear Activity class does not exist error restart Android Studio.

Thanks 🙂

Leave a Reply

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