在 sdk 管理器中找不到适用于 Android 库的 Google Cloud Messaging

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21678951/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 04:55:21  来源:igfitidea点击:

Google Cloud Messaging for Android Library not Found in the sdk Manager

androidgoogle-app-enginegoogle-cloud-messagingandroid-sdk-tools

提问by Hadj Ali Oussama

I am trying to implement a push notification solution for android.I am following the steps given in the following tutorial http://www.androidhive.info/2012/10/android-push-notifications-using-google-cloud-messaging-gcm-php-and-mysql/

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

but when i tried to install the Google Cloud Messaging for Android Library using the android sdk(i am using the latest sdk) i don't find it the extras module like you can see in this picture

但是当我尝试使用 android sdk(我使用的是最新的 sdk)为 Android 库安装 Google Cloud Messaging 时,我没有找到您在这张图片中看到的额外模块

enter image description here

在此处输入图片说明

This is really strange. Is there any solution?

这真的很奇怪。有什么解决办法吗?

回答by Anubhav

Select the 'Show Obsolete Packages' option in Packages menu and you will be able to view it and install.

在 Packages 菜单中选择“Show Obsolete Packages”选项,您将能够查看并安装它。

enter image description here

在此处输入图片说明

回答by Harshad Ranganathan

Install Google Play Services Library

安装 Google Play 服务库

enter image description here

在此处输入图片说明

For client side implementation of GCM use this link

对于 GCM 的客户端实现,请使用此链接

For server side purposes follow the tutorial

对于服务器端的目的,请遵循教程

Pls note that the tutorial explains how you can send messages to individual devices using the registration id and not to all devices at one go.

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

[Update]

[更新]

I observed that still some people are using the deprecated library - GCM for android.

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

"Google Cloud Messaging for Android" is deprecated and no more used.GCM API's are now available as part of "Google Play Services".

“Android 版 Google Cloud Messaging”已弃用,不再使用。GCM API 现在可作为“Google Play 服务”的一部分使用。

Eventhough @anubhav's answer is correct for the asked question it is not recommended.

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

回答by Denis Itskovich

Seems like this package is now obsolete. In order to see it in SDK Manager I had to check "Show obsolete packages" in the "Packages" menu

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

Edit (clarification of my answer)

编辑(澄清我的答案)

I encountered this problem when trying to run Maven Android SDK Deployer. The version of the SDK deployer I used, was expecting gcm package installed (at least when running the deployer in its default configuration).

我在尝试运行时遇到了这个问题Maven Android SDK Deployer。我使用的 SDK 部署器版本期望安装 gcm 包(至少在以默认配置运行部署器时)。

For other purposes, it's recommended to use the newer Google Play Servicesinstead, as stated in one of the answers here.

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

回答by pathe.kiran

To Add Google Play Services to Your Project (For Android Studio)

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

  1. Open the build.gradle (Module:app) file inside your application module directory.

  2. Add a new build rule under dependencies for the latest version of play-services.

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

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

For example:

例如:

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.Save the changes and click Sync Project with Gradle Filesin the toolbar.

3. 保存更改并单击工具栏中的Sync Project with Gradle Files

4.Open your app's manifest file and add the following tag as a child of the <application>element:

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

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

go here for more details :Setting up google play services

去这里了解更多细节:设置谷歌播放服务

回答by CommonsWare

Is there any solution?

有什么解决办法吗?

Use something newer than that tutorial. The old GCM API was deprecated last May and was replaced with a new one.

使用比该教程更新的内容。旧的 GCM API 在去年 5 月被弃用,并被一个新的API取代

回答by Ranjith Kumar

Just tick the "Obsolete" checkbox in Android SDK Manager popup.

只需在 Android SDK 管理器弹出窗口中勾选“过时”复选框。

回答by nicole

the Google Cloud Messaging for Android Library is obsolete,you can find it by do this: sdk manager --> packages(left corner)-->show obsolete packages,then you will see it.but google sugessts to use Googleplay Service instead.

Android 库的 Google Cloud Messaging 已过时,您可以通过执行以下操作找到它:sdk manager --> packages(left corner)-->show obsolete packages, then you will see it.but google sugessts to use Googleplay Service 相反。