Failed to resolve: com.android.support:appcompat-v7:29+

在Android Studio中,新建项目时,会报错ERROR: Failed to resolve: com.android.support:appcompat-v7:29.0.1 。或者是ERROR: Failed to resolve: com.android.support:appcompat-v7:29+

这是我的 build.gradle

apply plugin: 'com.grpt.xxx'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.1"
    defaultConfig {
        applicationId "com.application.app"
        minSdkVersion 14
        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.1'
    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'
}

之所以发生如上错误,是因为com.android.support:appcompat-v7:29.x.x 不存在

将替换 

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

 :

implementation 'androidx.appcompat:appcompat:1.0.2'

不过,项目庞大最好用Android Studio自带的选择项功能转移到AndroidX,自己手动替换上述,会导致项目需要手动重新导入AndroidX的包替换之前appcompat-v7的包。

Support Library 28.0.0的稳定版本,适合在生产中使用。这将是android.support包装下的最后一个功能版本,鼓励开发人员迁移到AndroidX。

注意:随着Android 9.0(API级别28)的发布,Jetpack包含了一个新版本的支持库AndroidX。AndroidX库包含现有的支持库,还包含最新的Jetpack组件。

您可以继续使用支持库。历史工件(那些版本为27和更早版本,并打包为android.support.*的工件)将在Google Maven上可用。但是,所有新的库开发都将在AndroidX库中进行。

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

可通过Android Studio自动将项目转到AndroidX:选中项目app,右键选择Refactor >> Refactor this >> migarat to AndroidX

Android studio如果找不到选择项,则需要升级Android studio版本。

猜你喜欢

转载自blog.csdn.net/qq_31622345/article/details/107408444