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

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

问题描述

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

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

参考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 但它给了我一些错误:

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:

  • 无法解析符号GCMBroadcastReceiver"
  • 无法解析符号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" />

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

I am using Android Studio and what I have done

  • 在 SDK 管理器中安装了 Google Play 服务并与 Gradle 同步
  • 在 build.gradle 中包含 compile 'com.google.android.gms:play-services:4.3.23'
  • 包含<代码><元数据android:name="com.google.android.gms.version"android:value="@integer/google_play_services_version"/> 在 AndroidManifest.xml 中
  • 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 是一个已弃用的类,您的项目中可能没有该类.您应该实现自己的广播接收器.GCMIntentService 是您应该实现的类.

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.

您使用的是旧教程,该教程使用已弃用的类,而不是使用 Google Play 服务库.您应该参考当前的官方 GCM 演示应用看看你的清单应该是什么样子,以及项目中应该有哪些类.

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天全站免登陆