繁体   English   中英

无法在Android Studio中添加依赖项

[英]Unable To add dependencies in android studio

如何使用build.gradle文件在android studio中添加库

这是我的build.gradle(Module)文件

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
    applicationId "com.example.akshay.popupdemo"
    minSdkVersion 19
    targetSdkVersion 23
    versionCode 7
    versionName "1.0.7"
    multiDexEnabled true
}
packagingOptions {
    exclude 'META-INF/LGPL2.1'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/NOTICE'
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
dexOptions {
    javaMaxHeapSize "4g"
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.google.android.gms:play-services:8.1.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.scottyab:secure-preferences-lib:0.1.3'
compile 'com.google.code.gson:gson:2.3'
compile 'com.esri.arcgis.android:arcgis-android:10.2.7'
}

和我的build.gradle(project)文件

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

allprojects {
    repositories {
        jcenter()
        maven {
            url 'http://dl.bintray.com/esri/arcgis'
        }
    }
}

我遇到了以下错误

   D:\Yogesh_Kadam_Projects\Android-Projects\Current Projects\PopUpDemo\app\build.gradle
    Error:Error:line (36)Failed to resolve: com.scottyab:secure-preferences-lib:0.1.3
    Error:Error:line (37)Failed to resolve: com.google.code.gson:gson:2.3
    Error:Error:line (38)Failed to resolve: com.esri.arcgis.android:arcgis-android:10.2.7

我知道如何使用库文件夹添加,然后使用项目结构对话框添加依赖项。

如何使用build.gradle文件添加库?

我应在android studio中进行什么设置以自行下载库? 请解释。

记录图像

@yogesh

尝试使用模块设置->依赖关系->库依赖关系添加依赖项

将依赖路径粘贴到ex的搜索区域。 com.google.code.gson:gson,这将搜索并纠正具有正确版本的依赖项

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM