Error:(26, 13) Failed to resolve: com.android.supp

2020-06-17 14:56发布

Error:(26, 13) Failed to resolve: com.android.support:appcompat-v7:25.0.1
Error:(23, 24) Failed to resolve: com.android.support.test.espresso:espresso-core:2.0

Here is my gradle file

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.1"
    defaultConfig {
        applicationId "com.example.jignesh.myapplication"
        minSdkVersion 25
        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 {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.0', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.0.1'
    testCompile 'junit:junit:4.12'
}

11条回答
爱情/是我丢掉的垃圾
2楼-- · 2020-06-17 15:45

The Espresso version you are using is outdated. You need to add the following version -

androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
androidTestCompile 'com.android.support.test:runner:0.5'

Please check their documentation - Espresso Docs

查看更多
家丑人穷心不美
3楼-- · 2020-06-17 15:46

Open SDK Manager -> Appearance & Behavior -> System Settings-> Android SDK

Download all the required platforms.

Thanks

查看更多
贪生不怕死
4楼-- · 2020-06-17 15:47

dependencies {

// compile fileTree(dir: 'libs', include: ['*.jar'])

compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support:design:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'

// testCompile 'junit:junit:4.12' }

查看更多
Animai°情兽
5楼-- · 2020-06-17 15:48

Issue resolved on commenting some lines in gradle

dependencies {

//    compile fileTree(dir: 'libs', include: ['*.jar'])

//    androidTestCompile('com.android.support.alert_dialog.espresso:espresso-core:2.2.2', {

//    exclude group: 'com.android.support', module: 'support-annotations'

//    })

    compile 'com.android.support:appcompat-v7:26.+'
    compile 'com.android.support:design:26.+'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'

//    testCompile 'junit:junit:4.12'
}
查看更多
Viruses.
6楼-- · 2020-06-17 15:52

Add the below line to your build.gradle.

androidTestCompile ('com.android.support.test.espresso:espresso-contrib:2.2.2'){
    exclude module: 'support-annotations'
    exclude module: 'support-v4'
    exclude module: 'support-v13'
    exclude module: 'recyclerview-v7'
    exclude module: 'appcompat-v7'
}

Another Approach to solve this.

configurations.all {
  resolutionStrategy {
      force 'com.android.support:support-annotations:23.0.1'
  }
}

Hope this will solve your problem.

查看更多
登录 后发表回答