2

I am new to Android App Development. I am trying to create an Android app using TabLayout and have added the following dependencies in the build.gradle file.

dependencies {
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:support-v4:25.3.1'
testCompile 'junit:junit:4.12'


 }

But on running the App, I am getting build error as follows

Error:(27, 0) Gradle DSL method not found: 'compile()' Possible causes:

  • The project 'MyFirstapp' 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
  • Any suggestions on why this problem is there. I get an option to install Plugin from Android Studio but I don't know which plugin to install.

    Pooja Arora
    • 574
    • 7
    • 19
    • http://stackoverflow.com/questions/27156428/getting-error-gradle-dsl-method-not-found-compile-when-syncing-build-grad – Stephen Apr 10 '17 at 07:51

    1 Answers1

    4

    I'm guessing you are adding dependencies to the wrong build.gradle.

    Try doing this: In your first build.gradle replace the dependencies with this

    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.0'
    }
    

    and replace dependencies in build.gradle(Module:app) (2nd build.gradle file) with this

    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
            exclude group: 'com.android.support', module: 'support-annotations'
        })
        compile 'com.android.support:appcompat-v7:25.3.1'
        compile 'com.android.support.constraint:constraint-layout:1.0.2'
        testCompile 'junit:junit:4.12'
    }
    
    Pang
    • 9,564
    • 146
    • 81
    • 122
    JBJ
    • 288
    • 2
    • 13
    • I have the same problem. I can't find com.android.support:appcompat-v7:25.3.1 . Please help me: http://i.imgur.com/cqPtiSg.png – MrSiro May 29 '17 at 11:43