如何修复无法解决:support-compat

WoW*_*W.j 4 android android-studio-3.0

为什么不帮我?

在我的应用程序中,我想使用ButterKnife库,然后添加该库依赖项。但是,当添加此库并单击“ 同步”按钮时。
无法同步项目,并显示错误。

gradle.Build(项目):

buildscript {

    repositories {
        google()
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.3'
        classpath 'com.jakewharton:butterknife-gradle-plugin:8.8.1'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
Run Code Online (Sandbox Code Playgroud)

gradle.build(app):

apply plugin: 'com.android.application'

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

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.jakewharton:butterknife:8.8.1'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
}
Run Code Online (Sandbox Code Playgroud)

错误信息 :

Failed to resolve: support-compat
Run Code Online (Sandbox Code Playgroud)

我该如何解决?

Gri*_*ani 6

请尝试添加排他线,但不包含应用程序紧凑支持组。

implementation 'com.jakewharton:butterknife:8.8.1',{
        exclude group: 'com.android.support'
    })
Run Code Online (Sandbox Code Playgroud)

  • 对于某些图书馆,我也面临着同样的问题。这是因为我们的buildToolsVersion与它们的库不兼容。图书馆已经更新了他们的buildToolsVersion,而我们还没有更新。这就是为什么ithink问题在那里。正确的原因是我也不知道。 (2认同)