无法解析:com.android.support:appcompat-v7:30.0.0

Piy*_*agi 3 android android-appcompat android-support-library android-studio androidx

我是初学者,在 Android Studio 中遇到此错误:-

错误:(26, 13) 无法解决: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'
}
Run Code Online (Sandbox Code Playgroud)

我使用 Android Studio 2.2.1 版本进行学习。任何帮助将不胜感激。

小智 7

android.useAndroidX=true
android.enableJetifier=true
Run Code Online (Sandbox Code Playgroud)

您可以将它们添加到 gradle.properties 文件中,这应该可以正常工作。我遇到了同样的问题,添加这些内容消除了错误。还可以尝试更新 Android studio 的所有插件和组件。


Gab*_*tti 6

这是因为支持库v.30 存在。

使用androidx库:

implementation 'androidx.appcompat:appcompat:1.1.0'
Run Code Online (Sandbox Code Playgroud)

或使用最后一个支持库:

implementation 'com.android.support:appcompat-v7:28.0.0'
Run Code Online (Sandbox Code Playgroud)