Android Studio 找不到任何与 com.Android.support: appcompat-v7: + 匹配的版本

在 Android Studio 中运行项目失败,并出现以下错误: could not find any version that matches com.android.support:appcompat-v7:+

我如何修复这个错误?

100484 次浏览

Open SDK Manager.exe in your Android Studio folder and install a matching API.

From Android Studio go to: Tools >> Android >> SDK Manager

Select and install "Extras|Android Support Repository"

Also as as said on How to update Android platform-tools in a headless linux?

 android list sdk


android update sdk --no-ui --filter extra

After installing Extras|Android Support Repository, It does not work for me. Then I change v7:1.6 to v7:1.8 in the app build.gradle file.

com.android.support:appcompat-v7:1.8.+! and It works for me.

I found all these answers incorrect for me. Instead in your android studio look below on the left. There will be some help for this.

For example, you will notice This support library should not use a different version (32) than the compilesdkVersion (23)

Then you change the version of to 23 like this

compile 'com.android.support:support-v4:23'

Now, you will see a message A newer version of com.android.support-v4 than 23 is available 23.4.0.

Thats how I knew that the correct version is 23.4.0

For me it worked after changing the version from 7:27.+ to 7:+

It is very simple. Kindly update and replace the below code in build.gradle(Project :App Name).

allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}

In Project > app > build.gradle file replace the line

implementation 'com.android.support:appcompat-v7:+'29.+'

with

implementation 'com.android.support:appcompat-v7:+'

and line

implementation 'com.android.support:design:29.+'

with

implementation 'com.android.support:design:+'

Then clean build

If you see this after you've just created a new project in Intellij then try to recreate it again with "Use AndroidX artifacts" checked

To whom came here for same error but version 29, change your support library to version 28:

build.gradle(app):

dependencies {
...
implementation 'com.android.support:appcompat-v7:28.+'
...
}

None of googled solutions worked for me. Then I saw Android has only support library up to version 28. It is weird that I got this error in an out-of-box created Android Studio project.

I'm not sure which Android Studio version was, cause I upgraded Studio after got error. Now in Android Studio 3.6.3, new projects coming with 'androidx.appcompat:appcompat:1.0.2'.

This worked for me to build and run this project. I had to add google in both sections.

build.gradle (project)

buildscript {
repositories {
google()
jcenter()


}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.2'


// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}


allprojects {
repositories {
jcenter()
google()
}
}

build.gradle(app)

apply plugin: 'com.android.application'






android {
compileSdkVersion 26
buildToolsVersion "29.0.2" //25.0.2"
defaultConfig {
applicationId 'com.github.nkzawa.socketio.androidchat'
minSdkVersion 17
targetSdkVersion 26
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}


dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
////noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:25.0.+'
////noinspection GradleCompatible
implementation 'com.android.support:recyclerview-v7:25.0.+'
implementation ('io.socket:socket.io-client:0.8.3') {
exclude group: 'org.json', module: 'json'
}


androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
testImplementation 'junit:junit:4.12'
}

Got the same error but version 26.

Downloading the libraries through the SDK Manager is no longer supported. The support libraries are now available through Google's Maven repository.

Solution:

In build.gradle (project) inside both buildscript/repositories and allprojects/repositories add this:

maven {
url 'https://maven.google.com/'
name 'Google'
}

Result:

buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'


// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}


allprojects {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
}


task clean(type: Delete) {
delete rootProject.buildDir
}

It worked for me.