Cannot resolve symbol 'GCMBroadcastReceiver' in Android Studio

17,219

com.google.android.gcm.GCMBroadcastReceiver is a deprecated class that you probably don't have in your project. You should implement your own broadcast receiver. GCMIntentService is a class you are supposed to implement.

You are using an old tutorial that uses deprecated classes instead of using the Google Play Services library. You should refer to the current official GCM demo app to see how your manifest should look like and which classes should be in the project.

Share:
17,219
Boy
Author by

Boy

Updated on June 05, 2022

Comments

  • Boy
    Boy about 2 years

    I am trying to use GoogleCloudMessaging (GCM) API for push notification in my Android app.

    Referring to http://www.androidhive.info/2012/10/android-push-notifications-using-google-cloud-messaging-gcm-php-and-mysql/ and http://developer.android.com/google/play-services/setup.html#Setup, I tried to set them up in AndroidManifest.xml but it gave me some error:

    • Cannot resolve symbol 'GCMBroadcastReceiver'
    • Cannot resolve symbol 'GCMIntentService'

    This block is in Application tag

        <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" />
                <!-- Receives the registration id. -->
                <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
    
                <category android:name="com.zaqqle.disqover" />
            </intent-filter>
        </receiver>
    
        <service android:name=".GCMIntentService" />
    

    I am using Android Studio and what I have done

    • installed Google Play Services in SDK Manager and synced with Gradle
    • included compile 'com.google.android.gms:play-services:4.3.23' in build.gradle
    • included <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /> in AndroidManifest.xml

    Could you help me point out where I have missed? Thank for any help!