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

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

如何修复此错误?

1
实际上这是对我有效的答案:https://dev59.com/imMl5IYBdhLWcg3w5KTd#18900369 - David
12个回答

195
从Android Studio转到:工具>> Android>> SDK管理器
选择并安装“Extras | Android支持库”。

16
值得一提的是,这并不等同于“Android Support Library”……你需要使用“Android Support Repository”。 - dwerner
7
我已安装支持库版本12,但仍然遇到此错误。 - IgorGanapolsky
1
谢谢!这也为我解决了一个问题,当我使用PhoneGap时,cordova build android会抛出类似的错误! - Giel Berkers
1
名称已更改为“支持库的本地Maven存储库”(v28) - n00dl3
4
界面已经改变了很多,以至于这些答案不再适用(适用于Android Studio 3.+)。唉。 - SMBiggs
显示剩余2条评论

23

在将版本从7:27.+更改为7:+后,对我有效。


哇...太棒了...当我添加相机插件时,出现了这个错误,然后通过将"compile "com.android.support:support-v4:27+"更改为"compile "com.android.support:support-v4:+"来解决。 - saber tabatabaee yazdi
它对我也起作用了。我尝试了清除缓存和将Maven添加到build.gradle,但都没有起作用。现在只需将版本7:30.+更改为7:+即可...非常感谢Osama Yaccoub。 - Jilson P Jose

18
在项目的app目录下的build.gradle文件中,替换该行:
implementation 'com.android.support:appcompat-v7:+'29.+'

使用

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

并且行

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

使用

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

然后进行干净的构建。


不要在版本中使用全局匹配,因为它可能会因版本更新而破坏代码。 - ruX

14

1
很遗憾,这在2020年(SDK 30)已经不再起作用了:“Filter extra not supported”。 - Silas S. Brown

11
非常简单。 请在 build.gradle(Project :App Name) 文件中更新并替换以下代码:

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


这适用于基于Gradle的项目,但如果您手动运行aaptjavacdx而没有使用Gradle,则帮助不大。 - Silas S. Brown

3
安装完Extras|Android Support Repository后,对我来说它并没有起作用。然后我在appbuild.gradle文件中将v7:1.6改为v7:1.8
使用com.android.support:appcompat-v7:1.8.+!,现在它可以正常工作了。

0

这对我来说是可行的,用于构建和运行此项目。我必须在两个部分中添加Google。

build.gradle(项目)

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'
}

构建和运行此项目:https://github.com/nkzawa/socket.io-android-chat - MPV

0

遇到了相同的错误,但版本是26。

通过SDK Manager下载库已不再受支持。支持库现在可通过Google的Maven存储库获得。

解决方案:

build.gradle(project)中,在buildscript/repositoriesallprojects/repositories中添加以下内容:

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

结果:

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
}

对我有用。


0
如果您在Intellij中创建了一个新项目后看到这个消息,那么请尝试再次创建并勾选“使用AndroidX构件”。

0
在你的Android Studio文件夹中打开SDK Manager.exe并安装相应的API。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接