Gradle同步失败:无法解析android.arch.core:common:1.1.0依赖
Let's break down what's causing this issue and how to fix it quickly:
Why this happens
The android.arch.core:common:1.1.0 dependency is part of Android's Architecture Components, which are hosted in Google's official Maven repository. Looking at your project-level build.gradle, your allprojects section doesn't include the google() repository—only jcenter and a third-party repo. That's why Gradle can't locate the jar even after searching jcenter.
Step-by-step fix
Update your project-level build.gradle
Open the rootbuild.gradlefile and addgoogle()to therepositoriesblock insideallprojects. Here's the corrected version:// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { jcenter() mavenCentral() google() } dependencies { classpath 'com.android.tools.build:gradle:3.1.2' classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2' classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1' classpath "io.realm:realm-gradle-plugin:3.7.2" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.41" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { google() // Add this line first jcenter() maven { url 'https://github.com/leonardocardoso/mvn-repo/raw/master/maven-deploy' } } }Pro tip: Putting
google()first helps resolve dependencies faster since it's the official source for Android core components.Optional: Add google() to your app module's repositories
If the above fix doesn't work immediately, you can also addgoogle()to therepositoriesblock in your app'sbuild.gradleto ensure the module can access the repo directly:repositories { google() maven { url 'https://maven.fabric.io/public' } mavenCentral() }Clean and sync your project
- Click
File > Sync Project with Gradle Filesin Android Studio. - If errors persist, try cleaning the project:
Build > Clean Project, then sync again. - For stubborn cache issues, delete the
.gradle/cachesfolder in your project directory and restart Android Studio.
- Click
Additional checks
- Confirm your Gradle version (3.1.2) is compatible with the Android Plugin you're using—3.1.2 works perfectly with Architecture Components 1.1.0.
- If you're behind a proxy, ensure Android Studio is configured to access external repositories correctly.
内容的提问来源于stack exchange,提问作者MrRobot9

