【问题标题】:Android Support Library - Failed to Resolve [duplicate]Android 支持库 - 无法解决 [重复]
【发布时间】:2018-01-09 01:55:12
【问题描述】:

我正在尝试将以下支持库添加到我的 buid.gradle:

 buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'
    }
}

apply plugin: 'com.android.application'

repositories {
    mavenCentral()
}

android {
    useLibrary 'org.apache.http.legacy'

    compileSdkVersion 26
    buildToolsVersion "23.0.3"

    defaultConfig {
        minSdkVersion 11
        targetSdkVersion 26

    }

    signingConfigs {
        release {

        }
    }

    buildTypes {
        release {
            signingConfig signingConfigs.release
        }
    }
}

repositories {
    jcenter()
}


dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.google.code.gson:gson:2.7'
    compile 'com.android.support:support-v7:26.0.0'
    compile 'com.android.support:appcompat-v7:26.0.0'
    compile 'com.android.support:cardview-v7:26.0.0'
    compile 'com.melnykov:floatingactionbutton:1.1.0'
    compile 'it.sephiroth.android.library.imagezoom:imagezoom:1.0.5'
    //Apptentive
    compile 'com.apptentive:apptentive-android:2.1.3@aar'
    //compile 'com.ToxicBakery.viewpager.transforms:view-pager-transforms:1.0.0'

}

我收到错误消息,指出每个库“无法解析”,然后是上面的每一行代码。我希望与最新的支持库保持同步,以获取常规支持、appcompat 和 cardview。

【问题讨论】:

  • 确保您已禁用离线模式。
  • 你能提供基本的说明吗?
  • 转到首选项 > Gradle 并取消选中“离线工作”。在 Android Studio 中打开设置并搜索离线它会找到包含离线工作的 Gradle 类别。你可以在那里禁用它。
  • 其实已经没有勾选了……

标签: android gradle android-support-library


【解决方案1】:

要使用从版本 26.0.0 开始的支持库,您需要将 Google 的 Maven 存储库添加到项目的 build.gradle 文件中,如 here 所述。

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

【讨论】:

  • 这实际上解决了我的问题。
【解决方案2】:

你的 buildToolsVersion 和 compileSdkVersion 是什么?

android {
    buildToolsVersion "26.0.1"
}

也许尝试在 AndroidManifest.xml 中更新它?有时它们不兼容,您必须相应地修改版本。

此链接可能会有所帮助:Setting up Gradle for api 26 (Android)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-04-16
    • 2018-02-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-15
    • 2011-08-18
    相关资源
    最近更新 更多