无法在android studio中添加依赖项

时间:2022-09-03 22:48:38

How to add Library in android studio using build.gradle file

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

Here is my build.gradle(Module) file

这是我的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'
}

and my build.gradle(project) file

和我的build.gradle(项目)文件

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

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

I Got The Following Error

我有以下错误

   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

I know how to add using library Folder and then adding dependencies using project structure dialog box.

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

How to add library using build.gradle file ?

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

What Setting should i made into android studio to download library by its own? Please Explain.

我应该在android studio中自己下载库做什么设置?请解释。

Log IMAGE

1 个解决方案

#1


0  

@yogesh

try to add dependencies using Module Setting -> Dependencies -> Library Dependency

尝试使用Module Setting - > Dependencies - > Library Dependency添加依赖项

paste dependency path on search area for ex. com.google.code.gson:gson and this will search & rectify the dependency with proper version

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

#1


0  

@yogesh

try to add dependencies using Module Setting -> Dependencies -> Library Dependency

尝试使用Module Setting - > Dependencies - > Library Dependency添加依赖项

paste dependency path on search area for ex. com.google.code.gson:gson and this will search & rectify the dependency with proper version

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