问题描述
继parse.com教程建立在Android推送通知( https://开头解析。 COM /教程/ Android的推送通知)。 IDE是在Mac OS特立独行的机器人工作室0.8.9。
错误 - >
不能使用GCM推送,因为应用程序清单缺少一些必需的声明
另外,请确保这些服务和广播接收器被宣布为的&lt儿童;用途>元件
logcat的输出 - >
10-13 23:12:10.430 4942-4962 / com.pixtas.sup E / com.parse.ManifestInfo:不能使用GCM推送,因为应用程序清单缺少一些必需的声明。请确保这些权限被声明为根&LT的儿童;清单>元件:
<使用-权限的Android:名称=android.permission.INTERNET对/>
<使用-权限的Android:名称=android.permission.ACCESS_NETWORK_STATE/>
<使用-权限的Android:名称=android.permission.VIBRATE/>
<使用-权限的Android:名称=android.permission.WAKE_LOCK/>
<使用-权限的Android:名称=android.permission.GET_ACCOUNTS/>
<使用-权限的Android:名称=com.google.android.c2dm.permission.RECEIVE/>
<允许机器人:名称=com.pixtas.sup.permission.C2D_MESSAGE安卓的ProtectionLevel =签名/>
<使用-权限的Android:名称=com.pixtas.sup.permission.C2D_MESSAGE/>
另外,请确保这些服务和广播接收器被宣布为的&lt儿童;用途>元件:
<服务机器人:名称=com.parse.PushService/>
<接收器的Android版本:NAME =com.parse.GcmBroadcastReceiver安卓权限=com.google.android.c2dm.permission.SEND>
<意向滤光器>
<作用机器人:名称=com.google.android.c2dm.intent.RECEIVE/>
<作用机器人:名称=com.google.android.c2dm.intent.REGISTRATION/>
<类机器人:名称=com.pixtas.sup/>
&所述; /意图滤光器>
< /接收器>
10-13 23:12:10.470 4942-4963 / com.pixtas.sup D / dalvikvm:GC_FOR_ALLOC释放199K,3%的自由7918K / 8156K,暂停34ms,共34ms
10-13 23:12:10.600 4942-4942 / com.pixtas.sup D / libEGL:加载/system/lib/egl/libEGL_tegra.so
10-13 23:12:10.630 4942-4942 / com.pixtas.sup D / libEGL:加载/system/lib/egl/libGLESv1_CM_tegra.so
10-13 23:12:10.640 4942-4942 / com.pixtas.sup D / libEGL:加载/system/lib/egl/libGLESv2_tegra.so
10-13 23:12:10.670 4942-4942 / com.pixtas.sup D / OpenGLRenderer:启用调试模式0
10-13 23:12:11.050 4942-4965 / com.pixtas.sup D / dalvikvm:GC_FOR_ALLOC释放265K,4%的自由8165K / 8468K,暂停23MS,总23MS
10-13 23:12:11.420 4942-4975 / com.pixtas.sup E / com.parse.PushService:试图用推,但这个程序是不是因为配置推:推没有配置这个应用程序,因为应用清单中缺少必需的声明。请加入以下声明你的应用程序清单为支持GCM以为PPN或为推(或两者)。要启用GCM支持,请确保这些权限被声明为根&LT的儿童;清单>元件:
<使用-权限的Android:名称=android.permission.INTERNET对/>
<使用-权限的Android:名称=android.permission.ACCESS_NETWORK_STATE/>
<使用-权限的Android:名称=android.permission.VIBRATE/>
<使用-权限的Android:名称=android.permission.WAKE_LOCK/>
<使用-权限的Android:名称=android.permission.GET_ACCOUNTS/>
<使用-权限的Android:名称=com.google.android.c2dm.permission.RECEIVE/>
<允许机器人:名称=com.pixtas.sup.permission.C2D_MESSAGE安卓的ProtectionLevel =签名/>
<使用-权限的Android:名称=com.pixtas.sup.permission.C2D_MESSAGE/>
另外,请确保这些服务和广播接收器被宣布为的&lt儿童;用途>元件:
<服务机器人:名称=com.parse.PushService/>
<接收器的Android版本:NAME =com.parse.GcmBroadcastReceiver安卓权限=com.google.android.c2dm.permission.SEND>
<意向滤光器>
<作用机器人:名称=com.google.android.c2dm.intent.RECEIVE/>
<作用机器人:名称=com.google.android.c2dm.intent.REGISTRATION/>
<类机器人:名称=com.pixtas.sup/>
&所述; /意图滤光器>
< /接收器>
要启用的支持,以为PPN,请确保这些权限被声明为根&LT的儿童;清单>元件:
<使用-权限的Android:名称=android.permission.INTERNET对/>
<使用-权限的Android:名称=android.permission.ACCESS_NETWORK_STATE/>
<使用-权限的Android:名称=android.permission.RECEIVE_BOOT_COMPLETED/>
<使用-权限的Android:名称=android.permission.VIBRATE/>
<使用-权限的Android:名称=android.permission.WAKE_LOCK/>
另外,请确保这些服务和广播接收器被宣布为的&lt儿童;用途>元件:
<服务机器人:名称=com.parse.PushService/>
<接收器的Android版本:NAME =com.parse.ParseBroadcastReceiver>
<意向滤光器>
<作用机器人:名称=android.intent.action.BOOT_COMPLETED/>
<作用机器人:名称=android.intent.action.USER_ preSENT/>
&所述; /意图滤光器>
AndroidManifest.xml中 - >
< XML版本=1.0编码=UTF-8&GT?;
<舱单的xmlns:机器人=http://schemas.android.com/apk/res/android
包=com.pixtas.sup>
//需要parse.com权限
<使用-权限的Android:名称=android.permission.INTERNET对/>
<使用-权限的Android:名称=android.permission.ACCESS_NETWORK_STATE/>
<使用-权限的Android:名称=android.permission.WAKE_LOCK/>
<使用-权限的Android:名称=android.permission.RECEIVE_BOOT_COMPLETED/>
<使用-权限的Android:名称=android.permission.VIBRATE/>
<使用-权限的Android:名称=android.permission.GET_ACCOUNTS/>
<使用-权限的Android:名称=com.google.android.c2dm.permission.RECEIVE/>
<! -
重要提示:在下面的线条变com.parse.tutorials.pushnotifications.permission.C2D_MESSAGE
以满足您的应用程序的包名+.permission.C2D_MESSAGE。
- >
<许可安卓的ProtectionLevel =签名
机器人:名称=com.pixtas.sup.permission.C2D_MESSAGE/>
<使用-权限的Android:名称=com.pixtas.sup.permission.C2D_MESSAGE/>
<应用
机器人:allowBackup =真
机器人:图标=@可绘制/ ic_launcher
机器人:标签=@字符串/ APP_NAME
机器人:主题=@风格/ AppTheme>
<活动
机器人:主名称=
机器人:标签=@字符串/ APP_NAME>
<意向滤光器>
<作用机器人:名称=android.intent.action.MAIN/>
<类机器人:名称=android.intent.category.LAUNCHER/>
&所述; /意图滤光器>
< /活性GT;
//注册parse.com服务和广播接收器
<服务机器人:名称=com.parse.PushService/>
<接收器的Android版本:NAME =com.parse.ParseBroadcastReceiver>
<意向滤光器>
<作用机器人:名称=android.intent.action.BOOT_COMPLETED/>
<作用机器人:名称=android.intent.action.USER_ preSENT/>
&所述; /意图滤光器>
< /接收器>
<接收器的Android版本:NAME =com.parse.GcmBroadcastReceiver
机器人:权限=com.google.android.c2dm.permission.SEND>
<意向滤光器>
<作用机器人:名称=com.google.android.c2dm.intent.RECEIVE/>
<作用机器人:名称=com.google.android.c2dm.intent.REGISTRATION/>
<! -
重要提示:改变com.parse.tutorials.pushnotifications,以配合您的应用程序包名称。
- >
<类机器人:名称=com.pixtas.sup.pushnotifications/>
&所述; /意图滤光器>
< /接收器>
<接收器的Android版本:NAME =com.parse.ParsePushBroadcastReceiver机器人:出口=假>
<意向滤光器>
<作用机器人:名称=com.parse.push.intent.RECEIVE/>
<作用机器人:名称=com.parse.push.intent.DELETE/>
<作用机器人:名称=com.parse.push.intent.OPEN/>
&所述; /意图滤光器>
< /接收器>
< /用途>
< /舱单>
code固定。想有三个问题:
1)错误的语法添加注释。我使用的是java / Objective-C的语法:
//这是一条评论
而不是XML的方式
<! - 这是一个注释 - >
2)类本来应该是<类机器人:名称=com.pixtas.sup/>
(谢谢疯抢)
3)根据需要添加的元数据通知图标。解析doc的说,这是可选的,但它似乎是强制性的,至少在某些情况下。 (Android - 无法启动接收器com.parse.ParsePushBroadcastReceiver )
<元数据
机器人:名称=com.parse.push.notification_icon
机器人:资源=@可绘制/ ic_launcher/>
(谢谢艾哈迈德·拉扎)
following the parse.com tutorial for setting up push notification on android (https://parse.com/tutorials/android-push-notifications). ide is android studio 0.8.9 on mac os maverick.
errors ->
Cannot use GCM for push because the app manifest is missing some required declarations
Also, please make sure that these services and broadcast receivers are declared as children of the <application> element
logcat output ->
10-13 23:12:10.430 4942-4962/com.pixtas.sup E/com.parse.ManifestInfo﹕ Cannot use GCM for push because the app manifest is missing some required declarations. Please make sure that these permissions are declared as children of the root <manifest> element:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission android:name="com.pixtas.sup.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="com.pixtas.sup.permission.C2D_MESSAGE" />
Also, please make sure that these services and broadcast receivers are declared as children of the <application> element:
<service android:name="com.parse.PushService" />
<receiver android:name="com.parse.GcmBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.pixtas.sup" />
</intent-filter>
</receiver>
10-13 23:12:10.470 4942-4963/com.pixtas.sup D/dalvikvm﹕ GC_FOR_ALLOC freed 199K, 3% free 7918K/8156K, paused 34ms, total 34ms
10-13 23:12:10.600 4942-4942/com.pixtas.sup D/libEGL﹕ loaded /system/lib/egl/libEGL_tegra.so
10-13 23:12:10.630 4942-4942/com.pixtas.sup D/libEGL﹕ loaded /system/lib/egl/libGLESv1_CM_tegra.so
10-13 23:12:10.640 4942-4942/com.pixtas.sup D/libEGL﹕ loaded /system/lib/egl/libGLESv2_tegra.so
10-13 23:12:10.670 4942-4942/com.pixtas.sup D/OpenGLRenderer﹕ Enabling debug mode 0
10-13 23:12:11.050 4942-4965/com.pixtas.sup D/dalvikvm﹕ GC_FOR_ALLOC freed 265K, 4% free 8165K/8468K, paused 23ms, total 23ms
10-13 23:12:11.420 4942-4975/com.pixtas.sup E/com.parse.PushService﹕ Tried to use push, but this app is not configured for push due to: Push is not configured for this app because the app manifest is missing required declarations. Please add the following declarations to your app manifest to support either GCM or PPNS for push (or both). To enable GCM support, please make sure that these permissions are declared as children of the root <manifest> element:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission android:name="com.pixtas.sup.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="com.pixtas.sup.permission.C2D_MESSAGE" />
Also, please make sure that these services and broadcast receivers are declared as children of the <application> element:
<service android:name="com.parse.PushService" />
<receiver android:name="com.parse.GcmBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.pixtas.sup" />
</intent-filter>
</receiver>
To enable PPNS support, please make sure that these permissions are declared as children of the root <manifest> element:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
Also, please make sure that these services and broadcast receivers are declared as children of the <application> element:
<service android:name="com.parse.PushService" />
<receiver android:name="com.parse.ParseBroadcastReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.USER_PRESENT" />
</intent-filter>
AndroidManifest.xml ->
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.pixtas.sup" >
// permissions required for parse.com
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<!--
IMPORTANT: Change "com.parse.tutorials.pushnotifications.permission.C2D_MESSAGE" in the lines below
to match your app's package name + ".permission.C2D_MESSAGE".
-->
<permission android:protectionLevel="signature"
android:name="com.pixtas.sup.permission.C2D_MESSAGE" />
<uses-permission android:name="com.pixtas.sup.permission.C2D_MESSAGE" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity
android:name=".Main"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
// register parse.com service and broadcast receivers
<service android:name="com.parse.PushService" />
<receiver android:name="com.parse.ParseBroadcastReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.USER_PRESENT" />
</intent-filter>
</receiver>
<receiver android:name="com.parse.GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<!--
IMPORTANT: Change "com.parse.tutorials.pushnotifications" to match your app's package name.
-->
<category android:name="com.pixtas.sup.pushnotifications" />
</intent-filter>
</receiver>
<receiver android:name="com.parse.ParsePushBroadcastReceiver" android:exported="false">
<intent-filter>
<action android:name="com.parse.push.intent.RECEIVE" />
<action android:name="com.parse.push.intent.DELETE" />
<action android:name="com.parse.push.intent.OPEN" />
</intent-filter>
</receiver>
</application>
</manifest>
code fixed. think there were three issues:
1) wrong syntax for adding comments. i was using the java/objective-c syntax:
// this is a comment
instead of xml way
<!-- This is a comment -->
2) category should have been <category android:name="com.pixtas.sup" />
(thank you berserk)
3) needed to add meta-data for notification icon. parse doc say this is optional, but it appears to be mandatory, at least in some cases. (Android - Unable to start receiver com.parse.ParsePushBroadcastReceiver)
<meta-data
android:name="com.parse.push.notification_icon"
android:resource="@drawable/ic_launcher" />
(thank you Ahmad Raza)
这篇关于错误设置使用parse.com和Android工作室推送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!