user2857001
user2857001

Reputation: 85

No WakefulBroadcastReceiver in Android GCM

I am following the guide to applying GCM client on android. However my extend WakefulBroadcastReceiver could not be found (WakefulBroadcastReceiver could not be resolved). Is it because of my manifest? I have changed the required packages to my project's package but it doesn't solve the issue

Here is my manifest:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.myapplication"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />

    <permission
        android:name="com.example.myapplication.permission.C2D_MESSAGE" />

    <uses-permission android:name="com.example.myapplication.permission.C2D_MESSAGE" />

    <uses-sdk
        android:minSdkVersion="14"
        android:targetSdkVersion="17" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/Theme.Sherlock.Light" >
        <activity
            android:name="com.example.myapplication.Login"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="com.example.myapplication.fragmentContainer" >
        </activity>

        <receiver
            android:name=".GcmBroadcastReceiver"
            android:permission="com.google.android.c2dm.permission.SEND" >
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />

                <category android:name="com.example.myapplication" />
            </intent-filter>
        </receiver>

        <service android:name=".GcmIntentService" />
    </application>

</manifest>

Upvotes: 0

Views: 3499

Answers (2)

user2857001
user2857001

Reputation: 85

Found the error, it was that my library is outdated. Updating sources in eclipse solved the problem

Upvotes: 1

Eyad Alama
Eyad Alama

Reputation: 199

I ran into the same problem recently, and what I did to fix it (After trying every other thing) was to rename my receiver to this:

 <receiver
        android:name="com.google.android.gcm.GCMBroadcastReceiver"
        android:permission="com.google.android.c2dm.permission.SEND" >
        <intent-filter>
            <!-- Receives the actual messages. -->
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
             <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
            <!-- Receives the registration id. -->
            <category android:name="your.package.name.GCMIntentService" />
        </intent-filter>

    </receiver>

      <service android:name="your.package.name.GCMIntentService" />

Also make sure that your GCMBroadcastReciever java file is in the root directory of your package.

Upvotes: 0

Related Questions