salma khalil
salma khalil

Reputation: 147

Failed to sync Gradle project Could not find method implementation() for arguments [com.android.support:design:27.1.0]

ERROR: Error:Could not find method implementation() for arguments [com.android.support:design:27.1.0] on DefaultExternalModuleDependency{group='com.android.support.test.espresso', name='espresso-core', version='2.2.2', configuration='default'} of type org.gradle.api.internal.artifacts.dependencies.DefaultExternalModuleDependency.

Please install the Android Support Repository from the Android SDK Manager. Open Android SDK Manager

build.gradle (Module app)

android {
    compileSdkVersion 28
    buildToolsVersion "28.0.2"
    defaultConfig {
        applicationId "com.example.salmakhalil.signupformwithdatabase"
        minSdkVersion 14
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
       // androidTestCompile 'com.android.support:support-annotations:27.1.0'
        exclude group: 'com.android.support', module: 'support-annotations'
       implementation 'com.android.support:design:27.1.0'
// implementation 'com.android.volley:volley:1.1.0'
//implementation 'com.android.support:appcompat-v7:27.1.0'
//        implementation 'com.android.support.constraint:constraint-layout:1.0.2'
//        implementation 'junit:junit:4.12'
//        implementation 'com.android.support.test:runner:1.0.1'
//        implementation 'com.android.support.test.expresso:expresso-core:3.0.1'
    })
    compile 'com.android.support:appcompat-v7:25.+'
    testCompile 'junit:junit:4.12'
}

How should I solve this problem?

**build.gradle** (Module App)
apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    buildToolsVersion "28.0.2"
    defaultConfig {
        applicationId "com.example.salmakhalil.signupformwithdatabase"
        minSdkVersion 14
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
/*    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
       // androidTestCompile 'com.android.support:support-annotations:27.1.0'
        exclude group: 'com.android.support', module: 'support-annotations'
       implementation 'com.android.support:design:27.1.0'
// implementation 'com.android.volley:volley:1.1.0'
//implementation 'com.android.support:appcompat-v7:27.1.0'
//        implementation 'com.android.support.constraint:constraint-layout:1.0.2'
//        implementation 'junit:junit:4.12'
//        implementation 'com.android.support.test:runner:1.0.1'
//        implementation 'com.android.support.test.expresso:expresso-core:3.0.1'
    })*/
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    implementation 'com.google.android.material:material:1.1.0-alpha09'

    compile 'com.android.support:appcompat-v7:25.+'
    testCompile 'junit:junit:4.12'
}

// 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:2.2.1'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
allprojects {
    repositories {
        maven { url 'http://repo1.maven.org/maven2' }
        // { url "https://jitpack.io" }
        //maven { url "https://maven.google.com" }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

/*configurations.all {
    resolutionStrategy.force 'com.android.support:support-annotations:27.1.0'
}*/```

Upvotes: 3

Views: 5784

Answers (3)

tariq
tariq

Reputation: 1

Change the following code from this:

implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})

To this:

androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.google.android.material:material:1.1.0-alpha09'

Then Add in gradle properties:

android.useAndroidX=true

Upvotes: 0

Gabriele Mariotti
Gabriele Mariotti

Reputation: 364868

First of all update the version of android plugin for gradle and the gradle version.

In the project build.gradle (top-level file) update the android plugin changing:

repositories {
        google() //<-- add
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.2' //change
    }
}

allprojects {
    repositories {
        google() //<-- add
        maven { url 'http://repo1.maven.org/maven2' }
    }
}

Then in gradle/wrapper/gradle-wrapper.properties change the gradle version using distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip.

To fix the issue in the question, in the module/build.gradle change:

   androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
       // androidTestCompile 'com.android.support:support-annotations:27.1.0'
        exclude group: 'com.android.support', module: 'support-annotations'
       implementation 'com.android.support:design:27.1.0'
    })

to:

androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2') {
    exclude group: 'com.android.support', module: 'support-annotations'
}
implementation 'com.android.support:design:27.1.0'

Upvotes: 3

Auxano Services
Auxano Services

Reputation: 84

Change

 androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
   // androidTestCompile 'com.android.support:support-annotations:27.1.0'
    exclude group: 'com.android.support', module: 'support-annotations'
   implementation 'com.android.support:design:27.1.0'
})

To

androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.google.android.material:material:1.1.0-alpha09'

Upvotes: 0

Related Questions