Android:Which one to use for package name? Manifest's packagename or Gradle applicationId?

后端 未结 6 1321
陌清茗
陌清茗 2020-12-17 15:11

I am using Android Studio version 2.1.2, and I am trying to implement Google Cloud Messaging to my app.

To be able to do that I hav

6条回答
  •  佛祖请我去吃肉
    2020-12-17 15:45

    There's a great support article about this here by Android Studio.

    Why are there two?

    • The final package that is used in your built .apk's manifest, and is the package your app is known as on your device and in the Google Play store, is the "application id" as specified in the gradle file.
    • 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.

    Which one should I edit to change my final package name
    The package name in Gradle will overwrite the package name in the Manifest. So you should change it in Gradle.

    If you would like to actually change the structure of your project, then you'd need to change your packagename in Manifest.xml

    For permissions
    In your particular case, the permissions, you ask which package name you should provide for Google Messaging. Since Google Messaging requires your final package name, you should enter your gradle packagename. If you're using flavours, you should do this dynamically as suggested by @alim's answer.

提交回复
热议问题