faild解决android studio core上的错误:2.2.2

时间:2016-11-26 09:27:28

标签: android android-studio

得到这4个错误:

Error:(23, 24) Failed to resolve: com.android.support.test.espresso:espresso-core:2.2.2
Error:(26, 13) Failed to resolve: com.android.support:appcompat-v7:24.0.0
Error:(27, 13) Failed to resolve: com.android.support:design:24.0.0
Error:Failed to resolve: com.android.support:support-v4:24.0.0

代码:

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.0"
    defaultConfig {
        applicationId "com.adir.remember"
        minSdkVersion 15
        targetSdkVersion 24
        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', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:24.0.0'
    compile 'com.android.support:design:24.0.0'
    compile 'com.google.firebase:firebase-appindexing:10.0.0'
}

如何修复上述错误?

2 个答案:

答案 0 :(得分:0)

您应该阅读有关配置构建的document,了解有关引用here

的更多信息

然后,在您的gradle中添加以下lib&#39>

for

希望它会有所帮助。!

答案 1 :(得分:0)

请确定您的图书馆,因为compileSdkVersionbuildToolsVersion两者都不同,所以请设置相同,不是必需的,但对我们来说更好。您的compile 'com.android.support:appcompat-v7:23.4.0'库版本也不同。请设置compileSdkVersion 24buildToolsVersion 24.0.0相同。我建议使用compileSdkVersionbuildToolsVersion,您的每个图书馆版本都是相同的 在我的情况下,我使用如下,它对我来说工作正常

    android {
        compileSdkVersion 24
        buildToolsVersion "24.0.0"

    }

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

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude module: 'support-annotations'
        exclude module: 'support-v4'
        exclude module: 'support-v13'
        exclude module: 'recyclerview-v7'
        exclude module: 'design'
        module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:24.0.0'
    compile 'com.android.support:design:24.0.0'
    compile 'com.google.firebase:firebase-appindexing:10.0.0'
}