构建App突发找不到play-services-basement.aar的问题求助
Yep, this exact problem has popped up for tons of developers recently—you’re definitely not alone! Let’s break down what’s going on and how to fix it:
Why This Happens
First off, the issue is almost certainly related to repository configuration or server-side changes at jcenter, not a naming convention problem (since your build worked fine yesterday with no code changes). Here’s the breakdown:
- Even though you can download the .aar directly via browser, Gradle relies on repository metadata (like
.pomfiles) to locate dependencies. It seems jcenter’s metadata for this specific Google Play Services artifact has become corrupted or is no longer being maintained properly. - Google has been moving its official libraries away from jcenter to its own
google()Maven repository over time, so jcenter’s copies of older Play Services versions may be unstable now.
Fixes to Try
Here are the most reliable solutions, ordered by effectiveness:
1. Prioritize the Google Maven Repository
Make sure the google() repository is listed first in your project-level build.gradle file. This tells Gradle to check Google’s official repo first for Play Services dependencies, instead of jcenter:
repositories { google() // Put this at the top mavenCentral() jcenter() // Can keep this for non-Google dependencies, or remove if unused }
2. Refresh Gradle Dependencies & Clear Cache
Sometimes Gradle’s cached dependency data gets stuck. Force a refresh with this command:
# On macOS/Linux ./gradlew clean build --refresh-dependencies # On Windows gradlew.bat clean build --refresh-dependencies
This will wipe old cached metadata and re-fetch dependencies from scratch.
3. Upgrade to a Newer Play Services Version (Optional)
Version 11.0.1 is pretty old—consider upgrading to a more recent stable version (like 11.8.0 or higher) if your app’s compatibility allows. Newer versions are better supported in Google’s own repository and less likely to have jcenter-related issues. Just update the dependency line in your module-level build.gradle:
implementation 'com.google.android.gms:play-services-basement:11.8.0'
Final Notes
The core issue here is jcenter’s declining support for Google’s libraries. Moving forward, it’s a good practice to rely on google() and mavenCentral() as your primary repositories for Android projects, since jcenter is in read-only mode and no longer receiving updates for many artifacts.
内容的提问来源于stack exchange,提问作者Simbaclaws

