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

2019-08-09 00:05发布

This is what my gradle file looks like http://codeshare.io/RWMpl , its throwing a small error saying:

gradle DSL method not found: '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()
    }
}

I followed the advice on THIS thread(see the accepted answer) , but i still get the following error:

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

Why ?

2条回答
一夜七次
2楼-- · 2019-08-09 00:14

You using a wrong gradle file. Check for build.gradle(Module:yourmodulename), this is where you have to update.

查看更多
爷的心禁止访问
3楼-- · 2019-08-09 00:16

Usually, there is a Project build.gradle and a Module build.gradle.

The screenshot that you shared was of your Module build.gradle.

This error seems to me as, you have an android block in your Project build.gradle file.

Remove android block from Project build.gradle and the app will compile fine..

查看更多
登录 后发表回答