Android Studio:未找到Gradle DSL方法:' classpath()'

时间:2015-02-19 19:12:45

标签: android android-studio

首先,我已阅读所有其他解决方案帖子以及有关迁移到1.0的官方文档。到目前为止,没有一个有效。

错误:

Error:(23, 0) Gradle DSL method not found: 'classpath()'
Possible causes:<ul><li>The project 'SparkDatabase' may be using a version of Gradle that does not contain the method.
<a href="open.wrapper.file">Open Gradle wrapper file</a></li><li>The build file may be missing a Gradle plugin.

申请Gradle插件

目前,这是我的build.gradle:

申请插件:&#39; com.android.application&#39;

android {
    compileSdkVersion 20
    buildToolsVersion "20.0.0"

    defaultConfig {
        applicationId "ca.industrycorp.sparkdatabase"
        minSdkVersion 19
        targetSdkVersion 20
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'de.greenrobot:greendao:1.3.7'
    compile 'de.greenrobot:greendao-generator:1.3.1'
    compile files('libs/json-simple-1.1.1.jar')
    compile files('libs/java-json.jar')
}

我的另一个朋友:

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

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

allprojects {
    repositories {
        jcenter()
    }
}

或者:如何完全安装Android Studio 1.0,只需开箱即用,而不必与之前的0.9相关联?

2 个答案:

答案 0 :(得分:3)

通过将classpath放在顶级build.gradle中,它解决了我的问题。

答案 1 :(得分:2)

有2个build.gradle文件。我在第一个添加类路径时发现了这个错误(所有符合依赖关系的文件)。另一个已经有一些类路径行(或者你称之为的任何行)。