Android SDK Google Play Service最新更新及无SDKManager直接下载咨询(含依赖错误)
Hey there, let's work through your Google Play Services SDK problem step by step!
1. 关于Google Play Services GCM的最新情况
First off, it's important to note that Google deprecated GCM (Google Cloud Messaging) a while back, folding its functionality into FCM (Firebase Cloud Messaging). The play-services-gcm dependency stopped receiving updates after the 12.0.x series—so versions like 12.0.+ are no longer maintained, and might even be removed from official repositories, which is likely why you're seeing that Failed to resolve error.
Right now, the actively supported alternative is Firebase Messaging, with the latest stable version being 23.4.0 as of mid-2024. It offers all the features of GCM plus improvements, so migrating is the long-term fix here.
2. 不使用SDK Manager/谷歌官方站点的下载方案
If you really need the old play-services-gcm package and can't use SDK Manager or Google's official sites, here's how to get it directly:
- The last stable version in the 12.0 series is
12.0.1. You can grab its AAR (Android Archive) file from public Maven repository mirrors:- Search for
com.google.android.gms:play-services-gcm:12.0.1on any public Maven mirror (like common domestic mirrors for easier access) - Download the
play-services-gcm-12.0.1.aarfile
- Search for
- Keep in mind: this dependency relies on other supporting packages, so you'll also need to download these AARs the same way:
play-services-basement:12.0.1play-services-tasks:12.0.1
- Once you have all the AAR files, move them to your project's
libsfolder, then add these lines to your app-levelbuild.gradleto use local dependencies:implementation files('libs/play-services-gcm-12.0.1.aar') implementation files('libs/play-services-basement-12.0.1.aar') implementation files('libs/play-services-tasks-12.0.1.aar')
3. 更推荐的长期解决方案:迁移到FCM
Since GCM is no longer supported, migrating to FCM will save you from future dependency issues. Here's the quick setup:
- Remove the old
com.google.android.gms:play-services-gcm:12.0.+line from yourbuild.gradle - Add the FCM dependency:
implementation 'com.google.firebase:firebase-messaging:23.4.0' - Follow standard FCM setup steps: add your
google-services.jsonfile to the app directory, configure the messaging service in your AndroidManifest, etc.
内容的提问来源于stack exchange,提问作者AhmadReza Molaei

