无法解析Android Studio中的符号'GCMBroadcastReceiver' [英] Cannot resolve symbol 'GCMBroadcastReceiver' in Android Studio

查看:254
本文介绍了无法解析Android Studio中的符号'GCMBroadcastReceiver'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正尝试在我的Android应用中使用GoogleCloudMessaging(GCM)API进行推送通知。

请参阅 http://www.androidhive.info/2012/10/android-push-notifications-using-google-cloud-messaging-gcm-php-and-mysql/ http://developer.android.com/google/play-services/setup.html#Setup ,我试图在AndroidManifest.xml中设置它们,但它给了我一些错误:


  • 无法解析符号'GCMBroadcastReceiver'

  • 无法解析符号'GCMIntentService'



此块位于应用程序标记

 < receiver 
android:name =com.google.android.gcm.GCMBroadcastReceiver
android:permission = com.google.android.c2dm.permission.SEND>
< intent-filter>

<! - - 接收实际的信息。 - >
<! - 接收注册ID。 - >

< category android:name =com.zaqqle.disqover/>
< / intent-filter>
< / receiver>

< service android:name =。GCMIntentService/>

我正在使用Android Studio以及我所做的事情


  • 在SDK Manager中安装了Google Play服务并与Gradle同步

  • 包含 compile'c​​om.google.android.gms: play-services:4.3.23' in build.gradle

  • 包括<元数据
    android:name = AndroidManifest.xml中的com.google.android.gms.version
    android:value =@ integer / google_play_services_version/>

>

你能帮我指出我错过的地方吗?感谢您的帮助!

解决方案

com.google.android.gcm.GCMBroadcastReceiver 是您的项目中可能没有的弃用类。你应该实现你自己的广播接收器。 GCMIntentService 是一个您应该实现的类。



您使用的旧教程使用不推荐的类,而不是使用Google Play服务库。您应该参考当前的官方GCM演示应用程序以看看你的清单应该是什么样的,以及项目中应该包含哪些类。

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!

解决方案

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.

这篇关于无法解析Android Studio中的符号'GCMBroadcastReceiver'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆