Error configuring push notification using parse.com and android studio
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 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 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>
+1
source to share
1 answer
fixed code. I think there were three problems:
1) incorrect syntax for adding comments. I used the java / objective-c syntax:
// this is a comment
instead of xml way
<!-- This is a comment -->
2) should have been <category android:name="com.pixtas.sup" />
(thank you berserk)
3), you need to add metadata for the notification icon. parse doc says this is optional, but it appears to be required, at least in some cases. ( Android - unable to launch receiver com.parse.ParsePushBroadcastReceiver )
<meta-data
android:name="com.parse.push.notification_icon"
android:resource="@drawable/ic_launcher" />
(thanks Ahmad Raza)
+3
source to share