gpt4 book ai didi

android - 无法在 Android Studio 中解析符号 'GCMBroadcastReceiver'

转载 作者:塔克拉玛干 更新时间:2023-11-02 07:57:14 27 4
gpt4 key购买 nike

我正尝试在我的 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”

这个 block 在应用程序标签中

    <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 以及我做了什么

  • 在 SDK 管理器中安装了 Google Play 服务并与 Gradle 同步
  • 包括compile 'com.google.android.gms:play-services:4.3.23'在 build.gradle 中
  • 包括<meta-data
    android:name="com.google.android.gms.version"
    android:value="@integer/google_play_services_version" />
    在 AndroidManifest.xml 中

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

最佳答案

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

您使用的旧教程使用了已弃用的类,而不是使用 Google Play 服务库。你应该引用当前的official GCM demo app查看您的 list 应该是什么样子以及项目中应该包含哪些类。

关于android - 无法在 Android Studio 中解析符号 'GCMBroadcastReceiver',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23517976/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com