找不到任何匹配 com.android.support:appcompat-v7:29.+ 的版本

Could not find any version that matches com.android.support:appcompat-v7:29.+

我在 Android 上达到了最新水平。刚刚启动一个新项目并在 Gradle Build with Pie ( Android v9.0):

上出错

Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not find any version that matches com.android.support:appcompat-v7:29.+.

这是我的 build.gradle (Module:app):


apply plugin: 'com.android.library'

android {
    compileSdkVersion 29
    defaultConfig {
        minSdkVersion 28
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:29.+'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

接下来我该怎么做?

尝试迁移到 Androidx

Android Studio > Refactor Menu > Migrate to AndroidX...

来自docs

With the release of Android 9.0 (API level 28) there is a new version of the support library called AndroidX which is part of Jetpack. The AndroidX library contains the existing support library and also includes the latest Jetpack components.

You can continue to use the support library. Historical artifacts (those versioned 27 and earlier, and packaged as android.support.*) will remain available on Google Maven. However, all new library development will occur in the AndroidX library.

We recommend using the AndroidX libraries in all new projects. You should also consider migrating existing projects to AndroidX as well.

您正在使用上次为 API 28 发布的支持库,但您正在尝试查找此库的 API 29 版本。 API 此库的 29 版本已移至另一个名为 AndroidX.

的库

转到 Android Studio 中的菜单栏,Select 重构然后迁移到 AndroidX,这应该可以解决问题。

这将用较新的 AndroidX 版本替换您正在使用的所有旧支持库包。 如果您在迁移后的依赖项中遇到任何错误,请从以下链接中找到您的依赖包并将其替换为 table:

中列出的较新的依赖包

https://developer.android.com/jetpack/androidx/migrate