Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between changing package name vs applicationId

Tags:

android

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
like image 464
Johns Avatar asked Feb 21 '17 12:02

Johns


People also ask

What is the difference between application ID and package name?

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.

Does package name matter?

myapp_name"? package Id (bundle Id is name used on iOS) does not really matter except for the moments you see it like in the case of play store links. Yet, the only thing that technically matters is to make it unique among all published apps (which it is the case, otherwise you would not be able to publish).

Is package name same as app name?

xml file of the Android app APK. Note that for some stores such as Amazon, the app ID is not the same as the package name. For additional help finding your app's package name, refer to your third-party app store's documentation. Note that package names and format can vary between stores.

What does it mean by package name?

A package name is the full name of the package, which is defined via the NAME parameter in the pkginfo file.


3 Answers

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.

like image 170
Eduardo Herzer Avatar answered Oct 03 '22 09:10

Eduardo Herzer


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."

like image 40
BabyishTank Avatar answered Oct 03 '22 08:10

BabyishTank


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

like image 36
Atef H. Avatar answered Oct 03 '22 08:10

Atef H.