You might wonder what is the difference between package name we have in AndroidManifest.xml file and ApplicationId we see in build.gradle. They seem to be the same thing, but actually they are 2 different things. So if you didn’t know what is the difference between these 2 properties, you can find out now.
- represents the package name used to identify your application in Google Play store and is used to build your apk’s manifest.
- once an app has been published to Gooogle Play store, the ApplicationId should never be changed
- it is declared in app/build.gradle file
- you can specify different applicationId for different versions of your app (flavors)
- if you do not declare the ApplicationId, it will have as default value, the name from AndroidManifest.xml, but this is not recommended as this way they will be coupled and any refactor on package name from manifest will lead to a rename in ApplicationId also (which is exactly what we want to avoid)
- represents the package name used in your source code to refer to your R class and imports.
- it is declared in AndroidManifest.xml file and is mandatory
- if you have multiple manifest files (like when using flavors) it is optional, but if you want to declare it, it must be the same as the one declared in the default AndroidManifest.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.
<?xml version="1.0" encoding="utf-8"?>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />