问题描述
我正在使用 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设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)