无法在依赖项build.gradle中添加支持库使用compile()

时间:2015-12-24 15:18:07

标签: android gradle

我阅读了如何从google开发者网站添加支持存储库 http://developer.android.com/intl/es/tools/support-library/setup.html 并导致构建文件错误

我无法找到关于相关主题的任何决议

这是我的build.gradlew

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.5.0'
        compile "com.android.support:appcompat-v7:23.1.0"
    }
}
apply plugin: 'android'

android {
    compileSdkVersion 'Google Inc.:Google APIs:23'
    buildToolsVersion '23.0.1'

    buildTypes {
        release {
            minifyEnabled true
            proguardFile getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
        }
    }
}

我得到了编译结果

> Could not find method compile() for arguments [com.android.support:support:23.1.0] on org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler_Decorated@37f86333.

1 个答案:

答案 0 :(得分:3)

您将buildscript dependenciesconfiguration dependencies混合:

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

// ...

repositories {
    mavenCentral()
}
dependencies {
    compile "com.android.support:appcompat-v7:23.1.0"
}