解析推送错误 "Cannot use GCM for push..." - Android

Parse Push error "Cannot use GCM for push..." - Android

我正在尝试为我的应用程序设置推送通知。我已遵循相应的快速入门指南和教程,据我所知,已正确设置所有内容,但是当我 运行 应用程序时,我收到以下 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>

我已经双重和三次检查,似乎我拥有错误所说的我需要的一切。有什么明显的东西是我在这里遗漏的吗?

其他可能相关的信息:

我的启动器activity

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();
 }
}

目前在我的其他 类 中没有任何与推送相关的内容。我尚未测试的一种可能性是我缺少 ParsePushBroadcastReceiver 子类导致了问题,但根据 Parse API 中的文档,这似乎不是基本推送服务所必需的。

我的完整清单,以备不时之需:

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

我很乐意提供所要求的任何更多信息,这就是我能想到的。在此先感谢您的帮助。

拜托。在我花了这么多时间之后,结果证明我只是另一个打字错误的受害者。虽然,我实际上并不知道打字错误是什么......我最终只是将错误日志复制并粘贴到我的清单中并删除时间戳(只留下建议的代码)并用它来替换相关行。我仍然看不出有什么不同,但它现在正在工作。我觉得很可笑。