我正在尝试为我的应用程序设置推送通知。我已经按照相应的快速入门指南和教程进行操作,据我所知,正确设置所有内容,但是当我运行应用程序时,我收到以下LogCat错误:
E/com.parse.ManifestInfo(17775): 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:
E/com.parse.ManifestInfo(17775): <uses-permission android:name="android.permission.INTERNET" />
E/com.parse.ManifestInfo(17775): <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
E/com.parse.ManifestInfo(17775): <uses-permission android:name="android.permission.VIBRATE" />
E/com.parse.ManifestInfo(17775): <uses-permission android:name="android.permission.WAKE_LOCK" />
E/com.parse.ManifestInfo(17775): <uses-permission android:name="android.permission.GET_ACCOUNTS" />
E/com.parse.ManifestInfo(17775): <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
E/com.parse.ManifestInfo(17775): <permission android:name="com.example.myapp.permission.C2D_MESSAGE" android:protectionLevel="signature" />
E/com.parse.ManifestInfo(17775): <uses-permission android:name="com.example.myapp.permission.C2D_MESSAGE" />
E/com.parse.ManifestInfo(17775): Also, please make sure that these services and broadcast receivers are declared as children of the <application> element:
E/com.parse.ManifestInfo(17775): <service android:name="com.parse.PushService" />
E/com.parse.ManifestInfo(17775): <receiver android:name="com.parse.GcmBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND">
E/com.parse.ManifestInfo(17775): <intent-filter>
E/com.parse.ManifestInfo(17775): <action android:name="com.google.android.c2dm.intent.RECEIVE" />
E/com.parse.ManifestInfo(17775): <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
E/com.parse.ManifestInfo(17775): <category android:name="com.example.myapp" />
E/com.parse.ManifestInfo(17775): </intent-filter>
E/com.parse.ManifestInfo(17775): </receiver>
以下是我的清单中的相关摘录:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="21" />
<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" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<permission android:name="com.example.myapp.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.myapp.permission.C2D_MESSAGE" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<!-- activities excluded to be concise -->
<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.example.myapp" />
</intent-filter>
</receiver>
<receiver android:name="com.parse.ParsePushBroadcastReceiver" >
<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.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>
<meta-data
android:name="com.parse.push.notification_icon"
android:resource="@drawable/push_icon" />
</application>
</manifest>
&#13;
我已经检查过双倍和三倍,看起来我有错误所说的一切我需要的东西。我有什么明显的遗失吗?
其他可能相关的信息:
我的发射器活动
public class StartActivity extends ActionBarActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Parse.initialize(this, "REDACTED", "REDACTED");
ParsePush.subscribeInBackground("");
ParseUser user = ParseUser.getCurrentUser();
Intent i;
if (user == null) {
i = new Intent(this, LogInActivity.class);
} else {
i = new Intent(this, MainActivity.class);
}
startActivity(i);
finish();
}
}
&#13;
目前没有任何与推送任何其他类相关的内容。我还没有测试过的一个可能性是我缺少ParsePushBroadcastReceiver子类会导致问题,但是根据Parse API中的文档,这似乎不是基本推送服务所必需的。 / p>
我的完整清单,万一需要:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="21" />
<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" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<permission android:name="com.example.myapp.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.myapp.permission.C2D_MESSAGE" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".LogInActivity"
android:label="@string/app_name" >
</activity>
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
</activity>
<activity
android:name=".ChatActivity"
android:label="@string/app_name"
android:windowSoftInputMode="stateHidden" >
</activity>
<activity
android:name=".StartActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<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.example.myapp" />
</intent-filter>
</receiver>
<receiver android:name="com.parse.ParsePushBroadcastReceiver" >
<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.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>
<meta-data
android:name="com.parse.push.notification_icon"
android:resource="@drawable/push_icon" />
</application>
</manifest>
&#13;
我很乐意提供所要求的更多信息,这是我能想到的。提前感谢您的帮助。
答案 0 :(得分:1)
韦尔普。经过我花在这上面的所有时间,事实证明我只是一个错字的另一个受害者。虽然,我实际上并不知道拼写错误是什么......我最后只是将错误日志复制+粘贴到我的清单中并删除时间戳(只留下建议的代码)并使用它来替换相关的行。我仍然无法看到差异,但它现在正在运作。我觉得很荒谬。