How to Change Package Name in Android Studio: Step-by-Step Guide for Developers
Changing the package name in Android Studio is a critical task for Android developers. Whether you are rebranding your app, creating different versions, or preparing it for the Play Store, understanding how to safely update your app’s package name is essential. A package name uniquely identifies your app, both on the device and in the Google Play Store, so incorrect handling can lead to errors or publishing issues.
What is a Package Name in Android?
In Android development, the package name is a unique identifier for your app, following a reverse domain notation such as com.example.myapp. It is used by the system to distinguish your app from others installed on a device.
Why the Package Name Matters
- Uniqueness: No two apps on the Play Store can share the same package name.
- App Updates: Changing it after publishing treats the app as a new one.
- Organization: Helps maintain a clean, structured project, especially if you manage multiple apps.
Reasons to Change the Package Name
There are several reasons why a developer might need to rename the package:
-
Rebranding the App: Align the package with a new app name.
-
Different App Versions: Create free and premium versions without conflicts.
-
Fixing Initial Errors: Correct mistakes made during project setup.
-
Publishing from a New Developer Account: Required if transferring apps or creating a new account.
Step-by-Step Guide to Change Package Name in Android Studio
Follow these steps carefully to ensure your app continues to work smoothly.
Step 1: Backup Your Project
Before making any changes, always create a backup of your project. This ensures you can recover the original version if something goes wrong.
Step 2: Update the Manifest File
- Open your project in Android Studio.
- Navigate to
app/src/main/AndroidManifest.xml. - Locate the
packageattribute at the top:
- xml
- <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.oldappname">
- Replace it with your new package name:
- xml
- <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.newappname">
Step 3: Refactor the Package Name in Code
- In the Project panel, switch to Android view.
- Expand
javaorkotlinfolder to see your package structure. - Right-click on the old package → Refactor → Rename.
- Select Rename Package (not just folder).
- Enter your new package name and click Refactor.
- Review changes and click Do Refactor.
This updates all references in your project automatically.
Step 4: Update applicationId in build.gradle
- Open
app/build.gradle. - Locate
applicationIdin thedefaultConfigblock: - gradle
applicationId "com.example.oldappname"
minSdkVersion 21
targetSdkVersion 34
versionCode 1
versionName "1.0"
- Replace the old package name with your new one:
- gradle
minSdkVersion 21
targetSdkVersion 34
versionCode 1
versionName "1.0"
- Sync your project with Gradle by clicking Sync Now.
Step 5: Clean and Rebuild Your Project
After refactoring, always clean and rebuild the project:
- Go to Build → Clean Project.
- Then Build → Rebuild Project.
This removes cached references to the old package and ensures smooth compilation.
Step 6: Update Dependencies and API Services
If your app uses Firebase, Google APIs, or third-party libraries, make sure to update the package name in those services as well. Failing to do so may cause runtime errors or authentication issues.
Common Issues and How to Fix Them
Even experienced developers can encounter problems after changing a package name. Here’s how to resolve common issues:
-
Duplicate Package Name Error: Ensure you updated both the manifest and
applicationId. -
Unresolved References: Clean and rebuild the project to refresh indexing.
-
Third-Party Dependencies: Check for libraries or plugins referencing the old package.
-
Signed APK Problems: Update signing configurations if they reference the old package.
Watch Video Tutorial for Better Understanding
For developers who prefer a visual guide, we’ve created a YouTube tutorial showing the entire package name change process. Watching the video makes it easier to follow along and reduces the chance of errors:
Watch Here: How to Change Package Name in Android Studio
Tips for a Smooth Package Name Change
- Always backup your project before making changes.
- Use consistent reverse domain notation for clarity (
com.domain.appname). - Test your app thoroughly on devices or emulators after refactoring.
- Update all APIs and services connected to your app.
- Document the change for future maintenance and team members.
Conclusion
Changing the package name in Android Studio may seem complicated, but with careful steps, it’s straightforward. By updating the manifest, refactoring the package, modifying Gradle, and rebuilding, you can safely rename your Android app without breaking functionality.
Refer to our YouTube tutorial for a visual step-by-step demonstration, and ensure you follow best practices for testing and backups. Proper package management helps keep your apps organized, professional, and ready for Play Store publishing.

No comments:
Post a Comment