【问题标题】:Could not find any version that matches com.android.support:appcompat-v7:29.+ [duplicate]找不到任何与 com.android.support:appcompat-v7:29.+ 匹配的版本 [重复]
【发布时间】:2019-08-09 06:12:44
【问题描述】:

我在 Android 上处于最新水平。刚启动一个新项目并在 Gradle Build with Pie (Android v9.0) 上出错:

无法解决依赖关系 ':app@debugAndroidTest/compileClasspath': 找不到任何版本 匹配 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'
}

接下来我该怎么做?

【问题讨论】:

标签: android build.gradle android-support-library android-appcompat


【解决方案1】:

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

转到 Android Studio 中的菜单栏,选择 Refactor 然后 Migrate to AndroidX,应该可以解决问题。

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

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

【讨论】:

    【解决方案2】:

    尝试迁移到 Androidx

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

    来自docs

    随着 Android 9.0(API 级别 28)的发布,有一个新版本 称为 AndroidX 的支持库,它是 Jetpack 的一部分。这 AndroidX 库包含现有的支持库以及 包括最新的 Jetpack 组件。

    您可以继续使用支持库。历史文物 (那些版本为 27 及更早版本,并打包为 android.support.*) 将在 Google Maven 上保持可用。但是,所有新图书馆 开发将在 AndroidX 库中进行。

    我们建议在所有新项目中使用 AndroidX 库。你 还应该考虑将现有项目也迁移到 AndroidX。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-10
      • 2017-10-28
      • 2015-10-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多