【问题标题】:Error in adding dependency in android在android中添加依赖时出错
【发布时间】:2016-09-11 05:30:53
【问题描述】:

当我成功构建以下代码时。

ext {
    supportLibVersion = '23.2.1'  // variable that can be referenced to keep support libs consistent
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile "com.android.support:appcompat-v7:${supportLibVersion}"
    compile "com.android.support:design:${supportLibVersion}"
    compile 'pl.pawelkleczkowski.customgauge:CustomGauge:1.0.1'
    compile "com.android.support:recyclerview-v7:${supportLibVersion}"
    compile "com.android.support:cardview-v7:${supportLibVersion}"
    compile 'com.rengwuxian.materialedittext:library:2.1.4'
    compile 'com.loopj.android:android-async-http:1.4.9'
    compile 'com.wdullaer:materialdatetimepicker:2.3.0'



}

但是当我添加下面的依赖项时,它说给了我错误。

 compile 'com.afollestad.material-dialogs:core:0.8.5.9'

错误

Error:Failed to resolve: com.android.support:appcompat-v7:23.4.0
<a href="install.m2.repo">Install Repository and sync project</a><br><a href="openFile">Open File</a><br><a href="open.dependency.in.project.structure">Show in Project Structure dialog</a>

任何建议。 谢谢

完整的 gradle 文件

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.zriton.udhaar"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
ext {
    supportLibVersion = '23.2.1'  // variable that can be referenced to keep support libs consistent
}
repositories {
    jcenter()
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile "com.android.support:appcompat-v7:${supportLibVersion}"
    compile "com.android.support:design:${supportLibVersion}"
    compile 'pl.pawelkleczkowski.customgauge:CustomGauge:1.0.1'
    compile "com.android.support:recyclerview-v7:${supportLibVersion}"
    compile "com.android.support:cardview-v7:${supportLibVersion}"
    compile 'com.rengwuxian.materialedittext:library:2.1.4'
    compile 'com.loopj.android:android-async-http:1.4.9'
    compile 'com.wdullaer:materialdatetimepicker:2.3.0'



    compile 'com.afollestad.material-dialogs:core:0.8.5.9'

}

【问题讨论】:

    标签: android android-studio dependencies


    【解决方案1】:

    您使用的支持库是 23.2.1,但错误显示为 23.4.0,请将您当前的版本替换为 23.4.0 并尝试同步项目

    【讨论】:

    • 能否提供完整的 gradle 文件,以便我找到其他解决方案?
    【解决方案2】:

    听起来您需要在 Android SDK Manager 中安装“Android Support Repository”。

    如果你的路径上有 android 工具,只需转到终端并运行:

    $ android

    您也可以通过 Android Studio > Tools > Android > SDK Manager 访问它。

    【讨论】:

      【解决方案3】:

      您没有安装最新版本的 Google 库。 23.2.1 应该是 23.4.0。

      解决方案在底部,“Install Repository

      【讨论】:

        猜你喜欢
        • 2016-07-16
        • 2016-02-19
        • 2016-09-11
        • 2022-01-14
        • 1970-01-01
        • 2020-12-08
        • 1970-01-01
        • 1970-01-01
        • 2021-10-28
        相关资源
        最近更新 更多