How to Rename Package in Android Studio

To rename the package name in Android Studio, you can follow these steps:

  1. Make sure you have a backup of your project or use version control (e.g., Git) to track the changes before renaming the package.
  2. In the Android project view, right-click on the package you want to rename, typically located under the “java” or “kotlin” directory.
  3. Select “Refactor” from the context menu, and then choose “Rename” or press the “Shift + F6” shortcut.
  4. In the Rename dialog, select the “Rename package” option.
  5. Enter the new package name in the “New name” field. Make sure to follow the package name conventions (e.g., com.example.myapp).
  6. Select the scope of the rename operation. By default, it should be set to the package and all its usages.
  7. Click “Refactor” to perform the package rename. Android Studio will update all references to the package throughout your project.
  8. Review the changes in the “Refactoring Preview” dialog to ensure that the renaming operation did not introduce any errors or unexpected modifications.
  9. Click “Do Refactor” to apply the changes.
  10. After the refactoring is complete, you may need to sync your Gradle files by clicking the “Sync Now” button that appears in the toolbar. This ensures that the package name is updated in your project’s configuration files.
  11. Clean and rebuild your project to verify that everything is working correctly with the new package name.

Note: Renaming the package name might affect some references and imports in your project. You may need to update any affected references manually if they are not automatically resolved by Android Studio.

It’s important to be cautious when renaming the package name, as it can have implications for resources, manifest files, dependencies, and more. Make sure to thoroughly test your app after the package name change to ensure its proper functioning.

Change Manually Package Name In Build Gradle App or Module