在sdk Manager中找不到适用于Android库的Google Cloud Messaging

时间:2014-02-10 13:47:20

标签: android google-app-engine google-cloud-messaging android-sdk-tools

我正在尝试为android实现推送通知解决方案。我正在遵循以下教程中给出的步骤http://www.androidhive.info/2012/10/android-push-notifications-using-google-cloud-messaging-gcm-php-and-mysql/

但是当我尝试使用android sdk(我使用的是最新的sdk)安装Google Cloud Messaging for Android Library时,我发现它不像你在这张图片中看到的额外模块

enter image description here

这真的很奇怪。 有没有解决方案?

7 个答案:

答案 0 :(得分:69)

选择'显示过时的套餐'选项卡菜单中的选项,您将能够查看并安装。

enter image description here

答案 1 :(得分:35)

安装Google Play服务库

enter image description here

对于GCM的客户端实施,请使用此link

出于服务器方面的目的,请遵循教程

请注意,本教程介绍了如何使用注册ID向各个设备发送消息,而不是一次性向所有设备发送消息。

<强> [更新]

我观察到仍有一些人正在使用已弃用的库 - GCM for android。

“Google Cloud Messaging for Android”已弃用,不再使用.GCM API现已作为“Google Play服务”的一部分提供。

尽管@ anubhav的答案对于提出的问题是正确的,但不建议这样做。

答案 2 :(得分:7)

好像这个包现在已经过时了。为了在SDK Manager中看到它,我必须在“Packages”菜单中选中“显示过时的包”

编辑(澄清我的回答)

尝试运行Maven Android SDK Deployer时遇到此问题。我使用的SDK部署程序的版本是期望安装gcm软件包(至少在默认配置中运行部署程序时)。

出于其他目的,建议使用较新的Google Play Services,如此处其中一个答案中所述。

答案 3 :(得分:3)

将Google Play服务添加到您的项目中(适用于Android Studio)

  1. 在应用程序模块目录中打开build.gradle(Module:app)文件。

  2. 在最新版本的播放服务的依赖项下添加新的构建规则。

  3. 例如:

    apply plugin: 'com.android.application'
    
    dependencies {
        compile 'com.android.support:appcompat-v7:21.0.3'
        compile 'com.google.android.gms:play-services:6.5.87'
    }
    

    3.保存更改并单击工具栏中的使用Gradle文件同步项目

    4.打开应用程序的清单文件,并将以下标记添加为<application>元素的子文件:

    <meta-data android:name="com.google.android.gms.version"
               android:value="@integer/google_play_services_version" />
    

    到此处了解更多详情:Setting up google play services

答案 4 :(得分:2)

  

有没有解决方案?

使用比该教程更新的内容。旧的GCM API去年五月已弃用,was replaced with a new one

答案 5 :(得分:1)

点击Android SDK Manager弹出窗口中的“过时”复选框。

答案 6 :(得分:1)

Google Cloud Messaging for Android Library已过时,您可以通过以下方式找到它:sdk manager - &gt;包(左上角) - &gt;显示过时的包,然后你会看到它。但google sugessts改为使用Googleplay服务。