Loading...

Rename or Change Package Name in Android Studio

Android application or game package name is very important for developer, because the package name serves as a unique identifier for the application and also unique in Google Play Store. Once you purchase application project with source code you need to change the package name of the application. The package name defines your application’s identity. But once you published your application in the market place, you cannot change the package name. If you change it, then it become new application in the play store (market place) and users of previous version cannot update to the new version.

In this tutorial you will learn to change or rename the package name of your android app from android studio. There are different ways to change package name in android studio and you will learn here. Renaming the package name on android studio is not much difficult. But also this article teaches you to change package name on android studio step by step, you can also follow similar ways in eclipse too.

Related:
How to Add a Library Project to Android Studio
Building First Android Application with Android Studio (Hello World Example)
How to Take Screenshot of Android Application in Android Emulator and Real Device from Android Studio
How to Remove/Delete Android Project from Android Studio

How to Change or Rename Package Name in Android Studio


Following are the steps to rename package name in android studio. If you want to change com.example.oldapp to com.example.newapp , then;

Renaming Package Name: Method 1


1. Create new package name in java directory

Go to java directory of your project (app or mobile/src/main/java), right click on that java directory > New > Package, enter your app new package (com.example.newapp) and confirm.

Rename or Change Package Name in Android Studio

2. Add Packages and Classes in New Package

Go to old package name (com.example.oldapp) select all packages and classes of old package name and copy and paste in to the new package (com.example.newapp). And click on Refactor button and then click Do Refactor.

3. Delete Old Package Name

Now you can delete old package name (com.example.oldapp).

4. Change Package Name in AndroidManifest.xml File

Open AndroidManifest.xml file and change all old package name with new one. (Change com.example.oldapp with com.example.newapp). Now clean the project top menu > Build > Clean Project.

5. Replace in Path

Right click on app/mobile directory > Replace in Path > set old package name and new package name, Case sensitive to true > Find > Replace > All Files. And again clean your project (top menu > build > clean project).

6. Synchronize Project

Go to top menu > tools > android > Sync Project with Gradle Files.


Renaming Package Name: Method 2


Rename or Change Package Name in Android Studio

1. Open project directory from left side.

2. Go to App Name/app/build/generated/source/r/debug/com/your old package without com. (example.oldapp)/R.

3. Open R.java file.

4. Right click on package name (oldapp) > Refactor > Rename > Rename Package > Enter your new package name here and click Refactor. And click Do Refactor from right bottom of android studio.

5. Open Module build.gradle file and change applicationId with new package name.(com.example.newapp).

6. Go to top menu > tools > android > Sync Project with Gradle Files.

That’s all. You have changes your android app package name using android studio. If you have any question regarding this topic please feel free to write in below comment box.
Tips-And-Tricks 6960544505736844336
Home item