错误:无法解析:com.android.support:appcompat-v7:29.0.0。

12

我安装了android 3.4.1后,正在设置我的android sdk 29,在此之后出现了停止并显示此错误:

ERROR: Failed to resolve: com.android.support:appcompat-v7:29.0.0。请问你能帮我解决吗?

构建gradle模块:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.0"
    defaultConfig {
        applicationId "com.example.testing"
        minSdkVersion 15
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:29.0.0'
    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'
}

构建Gradle项目

 // Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        google()
        jcenter()

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

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

allprojects {
    repositories {
        google()
        jcenter()

    }
}

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

没有支持库29.0.0。 - Basi
1个回答

13

随着发布了Android 9.0(API级别28),支持库也推出了一个新版本,称为AndroidX,它是Jetpack的一部分。

支持库版本28.0.0将是android.support包装下最后的功能发布,建议开发人员迁移到AndroidX

您仍然可以继续使用支持库。 历史文物(版本为27及更早版本,打包为android.support.*)将继续在Google Maven上提供。 但是,所有新库的开发都将在AndroidX库中进行。

有关更多AndroidX信息,请参阅此处


谢谢Basi,我明白了。 - Shahjad Ans Sunny
1
那你用什么替换它了?我尝试使用 "implementation 'androidx.appcompat.app:29.0.0'",但是出现了“解析失败”的错误。 - rmutalik
1
没有支持库版本29.0.0。 - Basi
1
@rmutalik,你需要将你的项目转换为androidX - Basi
1
在 gradle.properties 中添加 org.gradle.jvmargs=-Xmx1536m,android.useAndroidX=true 和 android.enableJetifier=true 就解决了问题。 - DocJ457

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