升级support库至27.1.1后同步项目遇Failed to resolve: support-core-utils错误求助
Hey there, let's get that frustrating dependency error sorted out. When upgrading to support library 27.1.1, this error usually pops up because of repository configuration issues, mixed dependency versions, or cached data. Here's what you can try:
1. Confirm Google Maven Repository is properly set up
Starting from support library 27.0.0, all support library artifacts are hosted exclusively on the Google Maven Repository. While your project-level build file already includes google() before jcenter(), double-check these details:
- The
google()repository is listed first in both thebuildscriptandallprojectssections (this ensures Gradle checks Google's repo first for dependencies) - If your app-level build file has its own
repositoriesblock, addgoogle()there too
2. Unify all support library versions
A common culprit is mixing different versions of Android Support Library dependencies. Every com.android.support: dependency in your app-level build file must use the same version (27.1.1 in your case). For example:
// Ensure all these match 27.1.1 implementation 'com.android.support:appcompat-v7:27.1.1' implementation 'com.android.support:support-core-utils:27.1.1' implementation 'com.android.support:design:27.1.1'
If third-party libraries are pulling in older versions of support-core-utils, you can force Gradle to use your desired version by adding this to your app-level build file:
configurations.all { resolutionStrategy.force 'com.android.support:support-core-utils:27.1.1' }
To identify exactly which library is causing the version conflict, run this command in your project root:
./gradlew app:dependencyInsight --dependency support-core-utils --configuration compile
3. Clean cached data and resync the project
Corrupted caches often mess up dependency resolution. Try these steps:
- Go to
File > Invalidate Caches / Restartin Android Studio, then select "Invalidate and Restart" - Manually delete the
.gradlefolders in your project root directory and your app module directory - Run
./gradlew cleanfrom the terminal, then click "Sync Project with Gradle Files" in Android Studio
4. Check Gradle plugin compatibility
Your current Gradle plugin version (3.1.0) is compatible with support library 27.1.1, but if the above steps don't work, try upgrading the plugin to a slightly newer compatible version. Update your project-level build file's classpath:
classpath 'com.android.tools.build:gradle:3.2.1'
Make sure your Gradle wrapper version matches (update distributionUrl in gradle/wrapper/gradle-wrapper.properties to use Gradle 4.6 or higher, e.g., https\://services.gradle.org/distributions/gradle-4.6-all.zip)
内容的提问来源于stack exchange,提问作者Ali Zarei

