【问题标题】:How do I use the latest support library (Getting failed to resolve error with support library 26.0.2 and compileSDKVersion 26)? [duplicate]如何使用最新的支持库(Getting failed to resolve error with support library 26.0.2 and compileSDKVersion 26)? [复制]
【发布时间】:2017-09-05 06:03:07
【问题描述】:

我已将 compileSdkVersion 更新为 26。这就是我的 gradle 文件现在的样子。

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.0"
    defaultConfig {
        applicationId ##############
        minSdkVersion 21
        targetSdkVersion 26
        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:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.android.support:recyclerview-v7:25.3.1'
    compile 'com.android.support:cardview-v7:25.3.1'
    testCompile 'junit:junit:4.12'
}

可以预见的是,我在支持库 (25.3.1) 和 CompileSdkVersion (26) 的版本中收到不匹配 (?) 的警告。

我已尝试将支持库版本更新为以下版本:

  • 编译'com.android.support:appcompat-v7:26.0.0'
  • 编译'com.android.support:appcompat-v7:26.0.2'

问题

他们都没有工作。两种情况都显示Failed to resolve 错误。点击 Install Repository and sync project 会冻结 Android Studio 几秒钟,然后什么也没有发生。

我错过了什么吗?

最新的Android支持版本库here26.0.2

【问题讨论】:

    标签: android android-gradle-plugin


    【解决方案1】:

    您应该将其添加到您的 App Level build.gradle 部分。

    终于

    allprojects {
        repositories {
            jcenter()
            maven {
                url "https://maven.google.com"
            }
        }
    }
    

    然后是 Clean-RebuildRun

    仅供参考

    如果您使用的是 Gradle higher than 4.1 版本,则必须使用:

    allprojects {
          repositories {  
            google()
    
        }
    }
    

    【讨论】:

      【解决方案2】:

      进入文件->设置->Android SDK->SDK工具。 然后在 Support Repository 下拉列表中,选中 android support repository 复选框并更新它。

      【讨论】:

      • 支持库不再通过可下载的 maven 存储库提供。版本 26 仅在 google repo 中可用。
      • 我没有使用 maven @EugenPechanec。
      • 我也不是,Maven 存储库!= Maven。
      猜你喜欢
      • 2023-03-10
      • 1970-01-01
      • 2017-08-02
      • 1970-01-01
      • 2013-05-29
      • 2022-12-27
      • 1970-01-01
      • 2018-04-14
      • 2023-04-03
      相关资源
      最近更新 更多