我在哪里可以将个别依赖项放在Android Studio中?

fel*_*lix 2 android gradle

我正在尝试安装Picasso(http://square.github.io/picasso/)以在Android Studio中使用.其中一个步骤是添加以下行:在依赖项下的build.gradle中编译'com.squareup.picasso:picasso:2.5.2'.但是,gradle中有一条消息告诉我不要在dependencies文件夹中插入单个依赖项.我该怎么办?

//顶级构建文件,您可以在其中添加所有子项目/模块共有的配置选项.

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

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}

allprojects {
repositories {
    jcenter()
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}
Run Code Online (Sandbox Code Playgroud)

JCu*_*ng8 5

您需要将它添加到位于"app"目录中的gradle.build文件中,而不是项目目录中的文件.找到位于项目"app"目录中的gradle.build文件.

这是我的例子:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 20
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "com.your.packagename" 
        minSdkVersion 15
        targetSdkVersion 21
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }



}

repositories { mavenCentral() }

dependencies {
    compile 'com.android.support:appcompat-v7:18.0.+'
    compile 'com.facebook.android:facebook-android-sdk:4.0.0'
    compile 'com.parse.bolts:bolts-android:1.+'
    compile 'com.parse:parse-android:1.+'

}
Run Code Online (Sandbox Code Playgroud)

以及一些支持文档的链接:http: //developer.android.com/tools/building/configuring-gradle.html