[Solved] Getting Error “Gradle DSL method not found: ‘compile()’” when Syncing Build.Gradle

Error after resolutionproject is staymax2 build.gradle files that i am working on To add V4 support libraries to android studio, i followed this document: but I get an error. Here is what i did

  1. SDK manager> Installed Android Support Library and Android Repository.
  2. Go to Build.Gradle and added the line as given in the dcoument. Build.Gradle now looks like this:

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

buildscript {
repositories {
dependencies {
    classpath ''

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

allprojects {
repositories {
    dependencies {

        compile ""


Then, I get a popup that suggest that I sync gradle. When i sync Gradle, i get this error:

Error:(20, 0) Gradle DSL method not found: ‘compile()’
Possible causes:

  • The project ‘staymax’ may be using a version of Gradle that does not contain the method.
    Open Gradle wrapper file
  • The build file may be missing a Gradle plugin.
    Apply Gradle plugin
  • Am i missing any step? Please suggest.


    apply plugin: ''
    android {
    compileSdkVersion 20
    buildToolsVersion "20.0.0"
    defaultConfig {
        applicationId "com.appt.shreyabisht.staymax"
        minSdkVersion 15
        targetSdkVersion 20
        versionCode 1
        versionName "1.0"
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), ''
    dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    Enquirer: shrbisht


    Solution #1:

    In almost all cases, your dependencies should be put into the individual module’s build.gradle files rather than at the top most level build.gradle file. In your case, that means the dependency should be added to the app module’s build.gradle file:

    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile ""

    And you should remove the entire allprojects part of the top level build.gradle.

    Respondent: shrbisht

    Solution #2:

    I have found that when I add an applicationSuffix or versionNameSuffix through the IDE menu (Build > Edit Build Types), it changes the dependencies section of my app build.gradle from this:

    dependencies {
        compile fileTree(include: ['*.jar'], dir: 'libs')
        testCompile 'junit:junit:4.12'
        testCompile 'org.json:json:20140107'
        compile "${supportLibVersion}" 
        compile "${supportLibVersion}" 
        compile "${supportLibVersion}" // VectorDrawableCompat
        compile "${supportLibVersion}" // AnimatedVectorDrawableCompat

    to this:

    dependencies {
        compile fileTree(include: ['*.jar'], dir: 'libs')
        testCompile 'junit:junit:4.12'
        testCompile 'org.json:json:20140107'
        compile "${supportLibVersion}" compile "${supportLibVersion}" compile "${supportLibVersion}"
        // VectorDrawableCompat
        compile "${supportLibVersion}"
        // AnimatedVectorDrawableCompat

    I don’t know why, but it combines the first three “compile” lines into one line, and moves the two comments (to the next line in each case).

    I solved the problem by editing the app build.gradle and putting each “compile” statement onto its own line.

    Respondent: ianhanniballake

    Solution #3:

    This worked for me:

    1. Exit Android Studio.
    2. Remove <home folder>/.gradle folder.
    3. Relaunch Android studio and let it load all gradle modules again.

    P.S.: Mine was a fresh project so I removed the project as well and created a new one, so there were no old gradle references from the project

    Respondent: C. Todd

    Solution #4:

    In my case, there are 2 build.gradle file in my project (it auto create by android studio when create new project)

    Just move the compile line to another one is solve my problem

    Respondent: Ankur A Sharma

    Solution #5:

    Hi everyone for me it was a “couple days consuming job” to make my app run in Android Studio . Finally I found that very simple way of it .

    1. Create libs folder under src/main/java/ it is App/java/libs in left pane .
    2. Copy and paste all your external jars into here.
    3. Goto left pane and right click on your App then click Open Module Settings
    4. Then Project Structure window will appear .
    5. Then move to Dependencies tab .
    6. Final Step : Add all your jars located in App/java/libs (You will find them in src/main/java/libs) one by one .

    That is all Enjoy it.

    Respondent: Grey Wolf

    Solution #6:

    Just delete the method.

    android {
    compileSdkVersion 21
    buildToolsVersion '21.1.2'

    Try to compile again. It should work now.

    Source :

    Respondent: katmanco

    Solution #7:

    I have the same issue, and the bug is my build.gradle of application level has dependencies of my submodules. Means

    dependencies {
       compile project(':library')
      compile project(':MPChartLib')

    I have just remove the two line inside the dependencies braces and it is able to start syncing.

    Respondent: Kamaro Lambert

    Solution #8:

    You have 2 different build.gradle (sometimes more depending on you)

    Only one of them is your app’s gradle, then the other one is project’s gradle.

    If you put your dependencies project’s gradle you can get error : Gradle DSL method not found: 'compile()'

    Put your dependencies in app’s build.gradle then it will work.

    Respondent: shailesh

    Solution #9:

    Deleting .gradle in my project folder did the job for me.

    Respondent: Yasin Kaçmaz

    Solution #10:

    Make sure you have a settings.gradle file in your project. Adding that solved the problem of Error:Gradle DSL method not found: 'minSdkVersion()' for me.

    Respondent: Samir

    The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

    Most Popular

    To Top
    India and Pakistan’s steroid-soaked rhetoric over Kashmir will come back to haunt them both clenbuterol australia bossier man pleads guilty for leadership role in anabolic steriod distribution conspiracy