3

This is my android gradle file. I am getting error android gradle plugin that does not contain the method (e.g. 'testcompile' was added in 1.1.0.). How can I fix this problem.

apply plugin: 'com.android.application'
android {
    compileSdkVersion 25
    buildToolsVersion "26.0.1"
    defaultConfig {
        applicationId "com.xxx.xxxx"
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
repositories {
    mavenCentral()
    jcenter()
}

dependencies {
    compile 'com.facebook.android:facebook-android-sdk:[4,5)'
    compile 'com.google.android.gms:play-services-auth:9.2.1'
    classpath 'com.android.tools.build:gradle:2.3.3'
    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:design:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile group: 'org.hibernate', name: 'hibernate-core', version: '3.6.7.Final'
    testCompile group: 'junit', name: 'junit', version: '4.+'
    compile 'com.android.support.test:runner:0.5'
}

Error

enter image description here

3 Answers 3

1

In your dependencies block you have to remove this line

classpath 'com.android.tools.build:gradle:2.3.3'

This line should be used in the buildscript block, something like:

buildscript {
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'
    }
}
Sign up to request clarification or add additional context in comments.

2 Comments

it didn't work. after the changes made as suggested by you
You should post the build.gradle in the root folder.
1

After the correction now the build. gradle looks like this and now i ge the the error as " Error:(20, 0) Gradle DSL method not found: 'classpath()' Possible causes:

  • The project 'WeatherApp' may be using a version of the Android Gradle plug-in that does not contain the method (e.g. 'testCompile' was added in 1.1.0). Upgrade plugin to version 2.3.3 and sync project
  • The project 'WeatherApp' 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
  • "

    apply plugin: 'com.android.application'
    
    android {
        compileSdkVersion 25
        buildToolsVersion "26.0.1"
        defaultConfig {
            applicationId "com.xx.xxxxx"
            minSdkVersion 15
            targetSdkVersion 25
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
            dependencies {
                classpath 'com.android.tools.build:gradle:2.3.3'
            }
        }
    }
    repositories {
        mavenCentral()
        jcenter()
    }
    dependencies {
        compile 'com.facebook.android:facebook-android-sdk:[4,5)'
        compile 'com.google.android.gms:play-services-auth:9.2.1'
        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:design:25.3.1'
        compile 'com.android.support.constraint:constraint-layout:1.0.2'
        compile group: 'org.hibernate', name: 'hibernate-core', version: '3.6.7.Final'
        testCompile group: 'junit', name: 'junit', version: '4.+'
        compile 'com.android.support.test:runner:0.5'
    }
    

    Comments

    0

    Remove classpath 'com.android.tools.build:gradle:2.3.3' from there and add it to your top-level build.gradle file.

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

    1 Comment

    it didn't work. after the changes made as suggested by you

    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.