2

When i want to add a new library to the build.gradle file it generate an error. this is my build.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.0.0'

        compile 'com.mcxiaoke.volley:library:1.0.+'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

and this is the error

C:\Users\Fakher\Documents\Play_Store_WS\VolleyJson\build.gradle Error:Error:line (10)Gradle DSL method not found: 'compile()' Possible causes:

  • The project 'VolleyJson' may be using a version of Gradle that does not contain the method. Gradle settings
  • The build file may be missing a Gradle plugin. Apply Gradle plugin

    3 Answers 3

    2

    You need to use the build.gradle of your module instead of your project.

    Sign up to request clarification or add additional context in comments.

    Comments

    1

    It doesn work because your putting the dependency in the wrong place, there are no plugins in that build.gradle to handle your dependency, you should add your dependency in the build.gradle located inside your app module.

    better explained:

    There is a folder called app inside your project, thats your app module, inside of it there should be a build.gradle, in that build.gradle there should be something like this:

     apply plugin: 'com.android.application'
    
    android {
        compileSdkVersion 21
        buildToolsVersion "21.1.2"
        defaultConfig {
        // bla bla bla
        }
    }
    dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    //put your dependencies here
    }
    

    Hope I could help you out....

    Comments

    1

    Look at this:

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

    Go for the build.gradle in your "App" module and then place :

    compile 'com.mcxiaoke.volley:library:1.0.+'
    

    Comments

    Your Answer

    By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

    Start asking to get answers

    Find the answer to your question by asking.

    Ask question

    Explore related questions

    See similar questions with these tags.