我正在使用 Android Studio 2.1.2 版,并且正在尝试将 Google Cloud Messaging 实施到我的应用中.
I am using Android Studio version 2.1.2, and I am trying to implement Google Cloud Messaging to my app.
为了能够做到这一点,我必须获取一个 Google 服务 json 文件(配置文件)以添加到我的项目中.
To be able to do that I have to obtain a Google Services json file(configuration file) to add to my project.
要从 Google Api 控制台面板获取此文件,我需要提供我的应用名称和我的应用程序包名称.这就是我的问题开始的地方.
For getting this file from Google Api console panel, I am required to provide my app name and my app's package name. And here is where my problem starts.
在我的应用中,Manifest 文件中的包名与应用程序级 build.gradle 文件中的 applicationId 不同.在 google play store 上,正在使用 applicationId.
In my app, package name in Manifest file is different than the applicationId in the application level build.gradle file. And On google play store, the applicationId is being used.
在我的清单文件中说明我的意思;
To Illustrate what I mean, In my Manifest file;
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapp">
在我的 gradle 文件中;
and in my gradle file;
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId 'com.menu.jkrk'
minSdkVersion 16
targetSdkVersion 23
versionCode 3
versionName "1.0"
}
现在,将哪一个作为包名提供给 google 以获取配置文件?
其次,在我的 manifest 文件中请求 C2D_MESSAGE 的权限时应该使用哪个格式;
<application-package-name> + ".permission.C2D_MESSAGE
感谢您的帮助.
将使用build.gradle中指定的应用程序id.
The application id specified in the build.gradle will be used.
AndroidManifest.xml 中的条目被覆盖
您的 AndroidManifest.xml 将如下所示
<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<receiver ...>
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="${applicationId}" />
</intent-filter>
</receiver>
这篇关于Android:使用哪一个作为包名?清单的包名或 Gradle applicationId?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
Android 上的数字软键盘Numeric Soft Keyboard on Android(Android 上的数字软键盘)
带有软键盘和“返回"的 EditText按钮EditText with soft keyboard and quot;Backquot; button(带有软键盘和“返回的 EditText按钮)
在 Android 上的应用程序中内置自定义“键盘&quoCustom #39;Keyboard#39; built in an application on Android(在 Android 上的应用程序中内置自定义“键盘)
如何在 Android 的移动网站中强制使用带有数字的How to force keyboard with numbers in mobile website in Android(如何在 Android 的移动网站中强制使用带有数字的键盘)
启动 Activity 时自动弹出键盘Automatic popping up keyboard on start Activity(启动 Activity 时自动弹出键盘)
如何制作 Android EditView“完成"按钮并在单击时How do I make an Android EditView #39;Done#39; button and hide the keyboard when clicked?(如何制作 Android EditView“完成按钮并在单击时隐藏