提问者:小点点

解析失败:com.android.support:AppCompat-V7:30.0.0


我是初学者,在Android Studio中出现了这个错误:-

错误:(26,13)无法解析:com.android.support:AppCompat-V7:30.0.0安装存储库并同步项目
在文件中显示
在项目结构中显示对话框

这是我的格雷代码:-

apply plugin: 'com.android.application'

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.0"
    defaultConfig {
        applicationId "com.example.piyushbairagi.demoapp"
        minSdkVersion 15
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:30.0.0'
    testCompile 'junit:junit:4.12'
}

我使用Android Studio 2.2.1版本用于学习目的。 任何帮助都将不胜感激。


共3个答案

匿名用户

发生这种情况是因为支持库V.30不存在。

使用androidx库:

implementation 'androidx.appcompat:appcompat:1.1.0'

或者使用上一个支持库:

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

匿名用户

支持库可用的最新版本是28.0.0

因此,您必须更新build.gradle,如下所示:

compile 'com.android.support:appcompat-v7:28.0.0'

Support library已停止使用。 因此,不要指望28.0.0之后会有新的发布。

谷歌现在支持AndroidX。 以某种(和基本的)方式,是同一件事。 所以,你可能要考虑将你的应用程序迁移到Android X上,以便获得谷歌的支持。

更多关于Android X的信息:

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

匿名用户

android.useAndroidX=true
android.enableJetifier=true

您可以将这些添加到gradle.properties文件中,这样可以很好地工作。 我有同样的问题,添加这些删除了错误。 同时尝试更新Android Studio的所有插件和组件。