android studio3.0使用butterknife

如果你的项目使用butterknife配置如下:

  • Project gradle config
repositories {
       google()
       jcenter()
       mavenCentral()
    }
dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0'
        classpath 'com.jakewharton:butterknife-gradle-plugin:8.8.1'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
allprojects {
    repositories {
        google()
        jcenter()
        mavenCentral()
    }
}
  • module gradle config
apply plugin: 'com.android.application'
apply plugin: 'com.jakewharton.butterknife'
dependencies {
    compile 'com.jakewharton:butterknife:8.8.1'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
}

出现以下错误:

Error:Unable to find method 'com.android.build.gradle.api.BaseVariant.getOutputs()Ljava/util/List;'.
Possible causes for this unexpected error include:
- Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.). Re-download dependencies and sync project (requires network)
- The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem. Stop Gradle build processes (requires restart)
- Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.
In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.

那么Use 9.0.0-SNAPSHOT for now:

  • 配置repositories url
repositories {
        ---
        maven {url "https://oss.sonatype.org/content/repositories/snapshots/"}
    }
allprojects {
    repositories {
        ---
        maven {url "https://oss.sonatype.org/content/repositories/snapshots/"}
    }
}.

然后将8.8.1改为9.0.0-SNAPSHOT

参考 butterknife issue

你可能感兴趣的:(android studio3.0使用butterknife)