gradle 未找到 DSL 方法:'compile()' 持续错误

gradle DSL method not found: 'compile()' persisting error

这就是我的 gradle 文件的样子 http://codeshare.io/RWMpl,它会抛出一个小错误:

gradle 未找到 DSL 方法:'compile()' .

My gradle file : 

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.2.3'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    compile 'org.ektorp:org.ektorp:1.4.2'
}

allprojects {
    repositories {
        jcenter()
    }
}

我遵循了 THIS 线程上的建议(请参阅已接受的答案),但我仍然收到以下错误:

gradle DSL method not found: 'compile()'.

为什么?

您使用了错误的 gradle 文件。检查 build.gradle(Module:yourmodulename),这是您必须更新的地方。

通常,有一个项目 build.gradle 和一个模块 build.gradle

您分享的屏幕截图是您的模块 build.gradle

这个错误在我看来是因为您的项目 build.gradle 文件中有一个 android 块。

从项目 build.gradle 中删除 android 块,应用程序将正常编译..