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:27

In android studio, tools->android->sdk manager->sdk tools-> update a android support repository rev 41.

查看更多
唯我独甜
3楼-- · 2020-06-17 15:31

See In your SDK tools which SKD you already Downloaded. And choice one of them like 21.3.4 ... note: must get below of buildToolsVersion and compiler your project.

查看更多
forever°为你锁心
4楼-- · 2020-06-17 15:32

you can use:

maven {
        url "https://maven.google.com"
    }

and it would solve the problem but I don't think its the most efficient way because when you do this you'll probably be getting rendering errors or warning on your activity.xml page and you don't want to risk that.

another way to solve this is to go to

tools ==> appearance and behavior ==> system settings ==> android SDK ==> SDK platforms and untick all android versions listed above android 7.0(Nougat).

close android studio and restart your project.

I use android 2.2 and have not upgraded to the latest so this solution might be different and not work on other android studio versions.

I hope this helps.

cheers

查看更多
ら.Afraid
5楼-- · 2020-06-17 15:37

Remove all SDK and SDK TOOL from SDK manager and reinstall

查看更多
贼婆χ
6楼-- · 2020-06-17 15:39

I honestly don't understand why this is not automatically catered for when you create a new project... Solution is to add

 maven {
            url "https://maven.google.com"
        }

under allprojects => repositories in project level build.gradle

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

You have to use maven repository too in your project gradle file -

allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
}

And sync your project, it will work :-)

查看更多
登录 后发表回答