Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle DSL method not found: 'testCompile()'

I am trying to build a project a Project in Android Studio. When I run the app, I get this error:

Error:(10, 0) Gradle DSL method not found: 'testCompile()'
Possible causes:
-The project 'AccurateCalculator' 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.2 and sync project.The project 'AccurateCalculator' 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

build.grade of the project has the following code:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.0'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

build.gradle of the module has the following code:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 17
    buildToolsVersion "25.0.2"

    defaultConfig {
        applicationId "calculator.app"
        minSdkVersion 14
        targetSdkVersion 17
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile 'com.android.support:support-v4:18.0.0'
    compile files('libs/achartengine.jar')
    compile files('libs/arity-2.1.6.jar')
    compile files('libs/ejml-0.21.jar')
    compile files('libs/slider.jar')
}
like image 843
userash Avatar asked May 27 '17 03:05

userash


People also ask

What is testCompile in gradle?

The testCompile configuration contains the dependencies which are required to compile the tests of our project. This configuration contains the compiled classes of our project and the dependencies added to the compile configuration.

What is testImplementation in gradle?

Configuration inheritance and composition For example the testImplementation configuration extends the implementation configuration. The configuration hierarchy has a practical purpose: compiling tests requires the dependencies of the source code under test on top of the dependencies needed write the test class.

Where do I change gradle version?

You can specify the Gradle version in either the File > Project Structure > Project menu in Android Studio, or update your Gradle version using the command line. The preferred way is to use the Gradle Wrapper command line tool, which updates the gradlew scripts. The following example sets the Gradle version to 7.4.

What is the difference between compile and implementation in gradle?

Fortunately, the implementation dependency configuration provides the same functionality as compile. You should always use implementation rather than compile for dependencies, as compile is now deprecated or removed in the case of Gradle 7+.


1 Answers

As the warning suggests, upgrading the plugin to 2.3.2 should resolve the issue:

classpath 'com.android.tools.build:gradle:2.3.2'
like image 102
azizbekian Avatar answered Oct 28 '22 23:10

azizbekian