使用android studio 3.1.1,我试图在项目中添加黄油刀,但是构建gradle失败了。
模块级别:

{   ...
    dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'

implementation 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'}

以下是构建项目级别:
buildscript {

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

    }
}

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

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

enter image description here
我从头开始重新创建了新项目,并测试了所有人所说的解决方案,但它不起作用,仍然失败,并显示以下消息:
Failed to resolve: support-compat

最佳答案

删除所有更改并添加:

  dependencies {
.
.
.
.
.
.

      implementation 'com.jakewharton:butterknife:8.8.1'
      annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'

    }

07-26 09:31