当Android studio 3.0+使用butterknif
2019-11-29 本文已影响0人
lystring
公司新开一个项目,换个方式撸,本来没准备用butterknife。然而我高估了我的耐心。。。
然后又回到了butterknife,然而居然报错。。。什么👻?不可能啊,之前还没问题的啊。崩溃ing...
环境
Android studio 3.4.1
butterknife 8.8.1
classpath 'com.android.tools.build:gradle:3.4.2'
错误日志
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.
最终解决方式
删除 applyplugin:'com.jakewharton.butterknife'
改为
android {
...
defaultConfig {
......
javaCompileOptions {
// 显式声明支持注解
annotationProcessorOptions {
includeCompileClasspath true
}
}
}
}