Rename Android App Package Name



Creating multiple APKs for different purposes.

Rename App ID and Package name for a React Native App. Rename Package Name in React Native. I am trying to change my application package name in Android. Click on rename package and do actual rename. In our case the package is renamed to – newapppackage: 3. Change ID of the Application (Name and Package also). Navigate to the applications section. There you can see all the apps. Click on the app for which you want to change the name of the icon.

If you rename the package name from manifest file, it will have NO impact on the applicationId even if they have the same name. We can also create multiple APKs through productFlavors like above. Remember, once an app has been published to Google Play store, the ApplicationId should never be changed. So, the applicationId matters. The package name is your App’s unique identity on Google Play Store. All future versions of the App need to have same package name in order to manage updates. App with a different package name can only be published as a different app with different name on the Play Store.

PackageName vs ApplicationId

Nowadays, many times we come to the situation that we need the APK with another different package name. Most of us do it easily, but sometimes we got stuck because of applicationId and packageName.We must know the difference between packageName and applicationId. And the other thing is Java package.

The following are the three which keeps us confusing:

  1. applicationId: BuildConfig.APPLICATION_ID
  2. packageName: getApplicationContext().getPackageName()
  3. Java package: BuildConfig.class.getPackage().toString()

Let’s see with an example

The following is the snippet from the gradle of a sample Android application.

Package

Here we will be having two different APKs. Weider pro olc.

  1. Release APK with com.mindorks.example.release
  2. Debug APK with com.mindorks.example.debug

The following is the snippet from manifest of the same sample Android application.

The following is the project package snippet of the same sample Android application. Optiarc dvd rw ad 5690h firmware download.

So, let’s create a debug APK and see what are the values of all the three.

Read the values carefully.

Matthew hussey pdf

The following shows the final AndroidManifest file after APK creation.

Rename Android App Package Name Android Studio

getPackageName gives the same applicationId which is created at the final moment from the gradle file and it overrides the AndroidManifest package. So the final AndroidManifest contains the same applicationId. So, the getPackageName is the same as the applicationId as the applicationId overrides the packageName in the AndroidManifest at the final moment.

Rename Android App Package Names

But for the Java code, the package is same as the project structure. The package that is used in your source code to refer to your R class, and to resolve any relative activity, service registrations, continues to be called the package as defined in your manifest. So, the AndroidManifest should have the package same as Java package to resolve relative activity, service.

Android

So, with the same java package, we can create any number of APKs with all unique applicationId.

But the final AndroidManifest contains the package as the unique applicationId only.

If you have to actually change the structure of your project, then you have to change your packageName in Manifest.xml.

If you rename the package name from manifest file, it will have NO impact on the applicationId even if they have the same name.

We can also create multiple APKs through productFlavors like above.

Remember, once an app has been published to Google Play store, the ApplicationId should never be changed.

Rename Android Package Name

So, the applicationId matters.

Happy Coding :)

Also, Let’s become friends onTwitter,Linkedin,Github, andFacebook.

While developing any Android application, generally it is the tendency of Android app developer to keep the PackageName as it is and not to change it. But at times, while uploading an application on Play store or due to some other constraints there could be a need to change the PackageName of Android application or some packages in the application.

Changing PackageName is a crucial part of any Android application as many of the core libraries and R.java file depends on the package name. Also, changing the package name was bit easy task for the Eclipse users, but this might not be the same in Android Studio as the package level names are not displayed in Eclipse style. i.e. In Eclipse, the packages are displayed with full parent hierarchy, but in Android Studio, it is displayed in a folder level hierarchy, so sometimes it looks bit difficult to change the PackageName.

Rename Android App Package Name

So in this article, I have tried to share some important guidelines to make this process easier. This is already documented in the Android Studio guide which is so huge that most of the time it is difficult to read everything of it. The purpose of sharing this feature separately is to highlight the steps, so it is easy for all Android developers to quickly change the PackageName when needed.

Below are the steps for changing the PackageName in Android studio.

  • Lets say, I want to change package name com.mycompanyname1.data to com.mycompanyname.data.
  • Click setting icon from Project explorer and check the Flatten package option.
  • Now again click on setting option and uncheck Hide Empty Middle Packages.
  • So now package name gets divided in different sub-package like com, com.mycompanyname1, com.mycompanyname1.data under java directory.
  • Right click on com.mycompanyname1 package name and click option Refactor->Rename option (Alt+Shift+R) then rename packagename dialog box opens up, just change the package name as you want. For current example, we changed mycompanyname1 to mycompanyname.
  • Click on Refactor button in dialog box.
  • Click on Do Refactor at bottom.
  • Android studio automatically changes package name in whole application except build.gradle.
  • Open build.gradle file under application, rename package name manually.
  • Now, again click on setting option and uncheck Flatten packages option.
  • Sync the application again and the code will be refactored according to new package.

For more clarity, you can also refer to the video shown below,

Hope this makes your life more easy now, to change the package name during Android app development. 🙂

If you have any questions, then comment box is open for it.

Author : RajMT

How To Rename Apps Android

About the Author
  • Android Team @ WeblineIndia

    We are Android experts @ WeblineIndia.We have developed lots of Android apps for various domains like - Business, Social, Medical, News, Sports, Education, etc. We also have expertise in custom SDK development.Following well defined standard development processes, coding standards, tools and techniques, it has always helped us to provide best mobile apps to our clients. Our main focus has always been to exceed client expectations and deliver easy to use technically strong apps. On the side, we also love contributing back to the community.Contact us if you want to develop an Android app.