【问题标题】:Failed to resolve: com.android.support:appcompat-v7:30.0.0无法解决:com.android.support:appcompat-v7:30.0.0
【发布时间】:2020-10-06 12:12:14
【问题描述】:

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

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

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

【问题讨论】:

    标签: android android-studio android-support-library android-appcompat androidx


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

      一般来说,问题在于您的 sdk 版本,只需检查它可能对应于您的依赖项版本 27.+ 或 26.0 等 ....

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

      【讨论】:

        【解决方案3】:
        android.useAndroidX=true
        android.enableJetifier=true
        

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

        【讨论】:

          【解决方案4】:

          支持库的最新版本是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

          【讨论】:

            【解决方案5】:

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

            使用 androidx 库:

            implementation 'androidx.appcompat:appcompat:1.1.0'
            

            或使用最后一个支持库:

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

            【讨论】:

              猜你喜欢
              • 1970-01-01
              • 2018-01-03
              • 2017-01-04
              • 2017-01-23
              • 2017-06-13
              • 2019-12-10
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              相关资源
              最近更新 更多