本文介绍了在android中添加依赖关系时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  ext {
supportLibVersion = '23 .2.1' //可以引用的变量,以保持支持libs一致
}

依赖关系{
编译fileTree(dir:'libs',include:['* .jar'])
compilecom.android.support:appcompat-v7:${supportLibVersion}
compilecom.android.support:design:${supportLibVersion}
compile'pl.pawelkleczkowski。 customgauge:CustomGauge:1.0.1'
compilecom.android.support:recyclerview-v7:${supportLibVersion}
compilecom.android.support:cardview-v7:${supportLibVersion}
compile'c​​om.rengwuxian.materialedittext:library:2.1.4'
compile'c​​om.loopj.android:android-async-http:1.4.9'
compile'c​​om.wdullaer: material.datetimepicker:2.3.0'



}

但是当我添加以下依赖关系时,它表示给我错误。

  compile'c​​om.afollestad.material-dialogs:core:0.8.5.9'

错误

 错误:无法解析:com.android.support:appcompat-v7:23.4.0 
< a href =install.m2.repo>安装存储库和同步项目< / a>< br>< a href =openFile>打开文件< / a>< br& ;< a href =open.dependency.in.project.structure>在项目结构对话框中显示< / a>

任何建议。
感谢



完成毕业文件

 应用插件: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion23.0.2

defaultConfig {
applicationIdcom .zriton.udhaar
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName1.0
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
}
}
}
ext {
supportLibVersion = '23 .2.1'//可以引用的变量来保持支持libs一致
}
存储库{
jcenter()
}

依赖关系{
编译fileTree(dir:'libs',include:['* .jar'])
编译com.android.support:appcompat-v7:${supportLibVersion
编译 com.android.support:design:${supportLibVersion}
compile'pl.pawelkleczkowski.customgauge:CustomGauge:1.0.1'
compilecom.android.support:recyclerview-v7:${supportLibVersion
compilecom.android.support:cardview-v7:${supportLibVersion}
compile'c​​om.rengwuxian.materialedittext:library:2.1.4'
compile'c​​om.loopj .android:android-async-http:1.4.9'
compile'c​​om.wdullaer:materialdatetimepicker:2.3.0'



compile'c​​om.afollestad .material对话框:core:0.8.5.9'

}


解决方案

您没有安装最新版本的Google的libs。 23.2.1应为23.4.0。



解决方案位于底部,安装存储库


When I have following code gradle is build successfully.

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'



}

But when I added below dependency it stated giving me error.

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

error

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>

Any suggestions.Thanks

complete gradle file

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'

}
解决方案

You don't have the latest version of Google's libs installed. 23.2.1 should be 23.4.0.

The solution is at the bottom, "Install Repository"

这篇关于在android中添加依赖关系时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-10 20:50