Build script error, unsupported Gradle DSL method found: 'compile()'!


(Fandi Akhmad) #1

Hello, i have problem when add .jar to my android Studio 0.5.4 I create libs folder inside /app so directory structure like this : app

  • build
  • libs

– my_jar.jar

  • src

And i add configuration to my build.gradle file, like this :

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.9.+'
          // I added this 2 lines to read my_jar.jar
        compile fileTree(dir:'libs', include:['*.jar'])
        compile files('libs/my_jar.jar')
    }
}
  allprojects {
    repositories {
        mavenCentral()
    }
}

When i sync gradle, i get this error message.

8:31:46 AM Gradle 'Valore' project refresh failed:
           Build script error, unsupported Gradle DSL method found: 'compile()'!
           Possible causes could be:
             - you are using Gradle version where the method is absent
            - you didn't apply Gradle plugin which provides the method
           - or there is a mistake in a build script
           Gradle settings

How to fix that error? Please help,

Thank you very much. :slight_smile:


(Luke Daley) #2

Looks like you forgot ‘apply plugin: “android”’.


(Rj Cristy) #3

^bobo!