新建Android项目编译报错:无法找到common.jar (android.arch.core:common:1.1.0)
Hey there! Let's get this issue sorted out step by step— I know how frustrating build errors can be when you're just starting a new project.
What's Causing This Error?
There are two key reasons you're hitting this problem:
- JCenter is deprecated: The
jcenter()repository you're using has been discontinued, and many official Android libraries (includingandroid.arch.core:common:1.1.0) are no longer hosted there. - Outdated Gradle Plugin: Your Gradle plugin version
2.2.2is extremely old. It doesn't support modern Android repository structures or newer library dependencies like the Architecture Components you're trying to use.
Step-by-Step Solutions
1. Update Your Root build.gradle
Replace your root-level build.gradle with this updated version. We'll switch to active, supported repositories and upgrade the Gradle plugin to a stable, modern version:
buildscript { repositories { google() mavenCentral() } dependencies { // Use a supported, up-to-date Gradle plugin classpath 'com.android.tools.build:gradle:7.4.2' } } allprojects { repositories { google() mavenCentral() } } task clean(type: Delete) { delete rootProject.buildDir }
Note: After making this change, Android Studio will likely prompt you to update the Gradle wrapper—just click "Update" to let it handle that automatically.
2. Verify Your App Module's build.gradle
Make sure your app-level build.gradle has compatible SDK settings and uses modern dependency syntax. Here's a baseline example to reference:
apply plugin: 'com.android.application' android { compileSdk 33 defaultConfig { applicationId "com.yourpackage.name" minSdk 21 targetSdk 33 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) // Use AndroidX libraries (the modern replacement for old android.arch packages) implementation 'androidx.core:core-ktx:1.9.0' implementation 'androidx.appcompat:appcompat:1.6.1' }
3. Sync and Clean Your Project
- Click the Sync Project with Gradle Files button (the elephant icon in Android Studio's toolbar).
- Go to
Build > Clean Project, thenBuild > Rebuild Project. - If issues persist, delete the
.gradlefolder in your project root and re-sync to clear cached data.
Your Project Creation Screenshots
Here are the setup screenshots you shared:



Original Configuration for Reference
Your original root build.gradle:
buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.2.2' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { jcenter() } } task clean(type: Delete) { delete rootProject.buildDir }
Your original settings.gradle:
include ':app'
内容的提问来源于stack exchange,提问作者G. Ciardini

