Android:哪一个用于包名? Manifest的包名或Gradle applicationId? [英] Android:Which one to use for package name? Manifest's packagename or Gradle applicationId?

查看:108
本文介绍了Android:哪一个用于包名? Manifest的包名或Gradle applicationId?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Android Studio版本2.1.2 ,并试图为我的应用实施 Google云消息传递



为了做到这一点,我必须获得Google Services json文件(配置文件)才能添加到我的项目中。



Google Api控制台面板中,我需要提供我的应用名称我的应用的软件包名称



在我的应用程序中,Manifest文件中的软件包名称与应用程序级别build.gradle文件中的applicationId不同。



为了说明我的意思,在我的Manifest文件中;



在google play store中,正在使用applicationId。

 < manifest xmlns:android =http://schemas.android.com/apk/res/android
package =com.example.myapp> ;

以及在我的gradle文件中;

 android {
compileSdkVersion 23
buildToolsVersion23.0.2
defaultConfig {
applicationId'com.menu.jkrk'
minSdkVersion 16
targetSdkVersion 23
versionCode 3
versionName1.0
}

现在,那些提供给google的包作为包名称来获取配置文件? 其次,哪一个应该用于请求在我的清单文件中格式为C2D_MESSAGE的信息;

 < application-包名称> +.permission.C2D_MESSAGE 

感谢您的任何帮助。

解决方案



AndroidManifest.xml 被覆盖

您的 AndroidManifest.xml 这个

 <使用权限android:name =$ {applicationId} .permission.C2D_MESSAGE/> 
<使用权限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/ >

< / intent-filter>
< / receiver>


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 have to obtain a Google Services json file(configuration file) to add to my project.

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.

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

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

Now, which one of those to provide to google as package name to get configuration file?

Secondly, which one should use for requesting permisson of C2D_MESSAGE in my manifest file where the format is;

<application-package-name> + ".permission.C2D_MESSAGE

Thanks for any help.

解决方案

The application id specified in the build.gradle will be used.

The entry in the AndroidManifest.xml is overridden

Your AndroidManifest.xml will look like this

<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:哪一个用于包名? Manifest的包名或Gradle applicationId?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆