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

后端 未结 6 1315
陌清茗
陌清茗 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条回答
  •  Happy的楠姐
    2020-12-17 15:44

    With introduction with Android Studio seen has been changed. Earlier in eclipse Manifest.xml package name considered whole and sole as you upload your app on Google Play store it will pick the package name from Manifest.xml but it is not the case with Android Studio.

    In Android Studio there are two place where application package name goes.

    1. Manifest.xml
    2. build.gradle

    build.gradle example

    defaultConfig {
        applicationId "com.company.testapp" 
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    

    Notice the applicationId above which is other place where package name goes.

    @Mdlc is absolutely right.

    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

    When we refactor rename application package name in Android Studio it does not change application Id. We have to do it manually. Please pay attention to this because it very important. As when we upload our application on Google Play store google pick package name matching with applicationId as in case of above example com.company.testapp.

提交回复
热议问题