text: This page describes useful app settings in the module-level
  build.gradle file
  that you will likely want to toggle. In addition to giving an overview of
  important properties set in the
  build.gradle file, we describe how you can:
  - Change the application ID for different build configurations.
  - Safely adjust the namespace independent of the application ID.
  Set the application ID
  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. Once you publish your app, you should never change the application ID. 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 what it was when originally published—if you change the application ID, Google Play Store treats the upload as a completely different app.
  Your application ID is defined = 15 targetSdk = 24 versionCode = 1 versionName = "1.0" } ... }
  Although the application ID looks like a traditional Java package name (your code’s namespace), Java-style package name you chose during setup. You
  can technically toggle the two properties independently from then on, but we
  don’t recommend it.
  Here is what we recommend when it comes to setting the application ID:
  - Keep the application ID the same as the namespace. The distinction between the the two properties can be a bit confusing, but if you keep them same, you have nothing to worry about.
  - Do not change the application ID after you publish your app. If you change it, Google Play Store will treat the subsequent upload as a new app.
  - Explicitly define the application ID. If the application ID is not explicitly defined using the
  applicationIdproperty, it automatically takes on the same value as the namespace. This means that changing the namespace changes the application ID, which is usually undesired..
  Set the namespace
  Every Android module has a namespace, which is used as the Java package name for
  its generated
  R and
  BuildConfig classes.
  Your namespace is defined by the
  namespace property in your module's
  build.gradle file, as shown in the folowing code snippet. The
  namespace is
  initially set to the Java-style package name you choose when you create your
  project.
  android { namespace 'com.example.myapp' ... }
  While building your app into the final application package (APK), the Android
  build tools use the namespace as the namespace for your app's generated
  R
  class (used to access your
  app resources).
  For example, in the preceding build file, the
  R class is created at
  com.example.myapp.R.
  As such, the name you set for the
  build.gradle file's
  namespace property
  should always match your project's base package name, where you keep your
  activities and other app code. Of course, you can have other sub-packages in
  your project, but those files must import the
  R class using the
  namespace from the
  namespace property.
  For a simpler workflow, you should keep your namespace the same as your application ID, as they are by default.
  Change the namespace
  For simplicity, you should try to keep the namespace and application ID the
  same, as they are by default. However, you may need to change the namespace at
  some point if you're reorganizing your code, or to avoid namespace collisions.
  In these cases, it is possible to, remember that the build tools copy
  the application ID into your app's final manifest file at the end of the build.
  So if you inspect your
  AndroidManifest.xml file after a build,
  don't be surprised that the
  package attribute has been set to the
  application ID. The merged manifest's
  package attribute is where: Do not set
  testNamespace and
  namespace to the same value, otherwise there will be namespace
  collisions.
  To learn more about testing, see Test apps on Android.