无法解析“com.google.android.gms.gcm.GcmReceiver”?

时间:2015-09-10 20:45:38

标签: java android push-notification google-cloud-messaging

我正在尝试在我的Android应用上实施GCM推送通知,并且我在此处遵循指南https://developers.google.com/cloud-messaging/android/client,但我在Android Studio中收到的错误是“不能解析符号:GcmReceiver“

我确实只是粘贴了我在清单指南中所说的内容并通过SDK Manager安装了Google Play服务,但它仍然告诉我它无法解决它。

enter image description here

我的理解是,这个类应该位于类路径的某个地方,现在我已经添加了库,考虑到所有其他类,如“MyGcmListenerService”,它有一个自定义包,而它有一个静态包。无论我在哪里看到这个问题都有帮助,有谁能告诉我我做错了什么?

我的代码(字面上只是从示例中粘贴的副本):

    <receiver
        android:name="com.google.android.gms.gcm.GcmReceiver"
        android:exported="true"
        android:permission="com.google.android.c2dm.permission.SEND" >
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            <category android:name="gcm.play.android.samples.com.gcmquickstart" />
        </intent-filter>
    </receiver>

1 个答案:

答案 0 :(得分:7)

检查是否已将依赖项添加到应用程序的级别gradle脚本中。

  

依赖项{compile&#34; com.google.android.gms:play-services:7.5。+&#34; }