22

What is the difference between changing package name vs applicationId to the final apk.

I know it is different for aspect of keeping source code, but lets say I got some app with package name a.b.c.d. What will be the difference in the builded apk file

  1. if I rename the a.b.c.d into q.w.e.r and then build the apk file

vs

  1. change the applicationId into gradle with q.w.e.r
Johns
  • 275
  • 1
  • 3
  • 5
  • Why lazy to google > https://developer.android.com/studio/build/application-id.html – Charuක Feb 21 '17 at 12:18
  • 7
    I am not lazy, I just need experience from other people for repercussions that I can not see at first sight. My plan is to keep the same package name across apps and change only the applicationId before publishing on store. But I can not see if there will be some kind of hidden issues with this kind of procedure. – Johns Feb 22 '17 at 09:53

4 Answers4

42

The package name is just to organize your code.

The applicationId, on the other hand, is used to identify your app in the Play Store. You will change this only if you plan to generate another app based on same code.

From docs (https://developer.android.com/studio/build/application-id.html):

When you create a new project in Android Studio, the applicationId exactly matches the Java-style package name you chose during setup. However, the application ID and package name are independent of each other beyond this point. You can change your code's package name (your code namespace) and it will not affect the application ID, and vice versa (though, again, you should not change your application ID once you publish your app). However, changing the package name has other consequences you should be aware of, so see the section about modifying the package name.

Eduardo Herzer
  • 2,033
  • 21
  • 24
  • 1
    So if I have some template, when I clone that template all I need is to change the applicatioId, right ? That is all I need to do before publishing to play store ? I could keep the package name the same across my apps ? – Johns Feb 22 '17 at 09:49
  • @Johns exactly. The only thing that makes an app unique is the applicationId – Eduardo Herzer Feb 22 '17 at 11:34
  • Also, the authorities specified in the Android manifest should be unique. – sharib ahmed Jun 14 '22 at 07:02
7

Some Android API like google map and firebase ask for your package name when you create the key. That package name they refer to is actually your applicationId. Yup Google insist on using the term package name for these API key. Don't get it confuse.

Taken from doc (https://developer.android.com/studio/build/configure-app-module#set_the_application_id):

"Note: The application ID used to be directly tied to your code's package name; so some Android APIs use the term "package name" in their method names and parameter names, but this is actually your application ID. For example, the Context.getPackageName() method returns your application ID. There's no need to ever share your code's true package name outside your app code."

BabyishTank
  • 1,329
  • 3
  • 18
  • 39
3

Application id mostly used for:

  • Change the application ID for testing

  • Change the application ID for build variants

In this case, each build variant should be defined as a separate product flavor. For each flavor inside the productFlavors {} block, you can redefine the applicationId property, or you can instead append a segment to the default application ID using applicationIdSuffix, as shown here:

Every Android app has a unique application ID that looks like a Java package name, such as com.example.myapp. This ID uniquely identifies your app on the device and in Google Play Store. If you want to upload a new version of your app, the application ID (and the certificate you sign it with) must be the same as the original APK—if you change the application ID, Google Play Store treats the APK as a completely different app. So once you publish your app, you should never change the application ID.

And package name is:

Although your project's package name matches the application ID by default, you can change it. However, if you want to change your package name, be aware that the package name (as defined by your project directory structure) should always match the package attribute in the AndroidManifest.xml file, as shown here:

The Android build tools use the package attribute for two things:

1- It applies this name as the namespace for your app's generated R.java class.

Example: With the above manifest, the R class will be com.example.myapp.R.

2- It uses it to resolve any relative class names that are declared in the manifest file.

Example: With the above manifest, an activity declared as is resolved to be com.example.myapp.MainActivity.

Know more from Source

Atef Hares
  • 4,715
  • 3
  • 29
  • 61
0

Once you upload the app on Play store you can't change the application id for that project , if you want to do then google play store consider as a different application.

In case of package name you can change it as you want.

Zakir hussain
  • 392
  • 1
  • 10