Android - ApplicationID 和 package 必须相同吗?

Android - ApplicationID and package must be the same?

这两者有什么区别? 如果ApplicationID和package不一样,会出什么事吗?

谢谢。

来自ApplicationId versus PackageName

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

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

在清单中你得到了包名

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapp" <!--this is package name-->
android:versionCode="1"
android:versionName="1.0" >

并且在 Gradle 文件中 ApplicationId

android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
 applicationId 'com.example.myapp'  //ApplicationID
  minSdkVersion 16
  targetSdkVersion 23
  versionCode 1
  versionName "1.0"
}

Doc

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

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