解析失败:com.android.support:appcompat-v7:30.0.0

Failed to resolve: com.android.support:appcompat-v7:30.0.0

我是新手,在 Android Studio 中遇到此错误 :-

Error:(26, 13) Failed to resolve: com.android.support:appcompat-v7:30.0.0 Install Repository and sync project
Show in File
Show in Project Structure dialog

这是我的 gradle 代码 :-

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 版本进行学习。任何帮助将不胜感激。

这是因为支持库 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'

支持库已停止。所以,不要指望 28.0.0 之后会有任何新版本发布。

Google 现在支持 AndroidX。在某种(和基本)方式上,是同一件事。因此,您可能需要考虑将您的应用程序迁移到 Android X 以获得 Google.

的支持

有关 Android X 的更多信息:

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

android.useAndroidX=true
android.enableJetifier=true

您可以将这些添加到 gradle.properties 文件中,这应该可以正常工作。我有同样的问题并添加这些删除了错误。也尝试更新 Android 工作室的所有插件和组件。

一般来说,问题出在您的 sdk 版本上,只需检查它是否与您的依赖项版本 27.+ 或 26.0 等相对应....

只需检查您的 sdk 版本,它可能与您的应用所需的版本相对应,如图中所示

此错误可能是由于您没有在 Android Studio 中安装更新的 Gradle 和 sdk。 您必须安装这些更新版本或更改 targetsdk 版本和 sdk 版本并将 appcompact 编译为您在 pc 中安装的版本,如图所示。enter image description here