我正在尝试使用 Android Studio 2.2 运行我的项目,但出现此错误
Unsupported method: AndroidProject.getPluginGeneration().
The version of Gradle you connect to does not support that method.
我正在使用 ButterKnife 8.4.0
我的应用程序 gradle.file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
}
我的模块 gradle 文件:
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "xxx.xx"
minSdkVersion 10
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
}
dependencies {
compile 'com.jakewharton:butterknife:8.4.0'
apt 'com.jakewharton:butterknife-compiler:8.4.0'
}
为什么它不起作用,我该如何解决?
最佳答案
一般问题:-
这可能是因为 AS 正在检查 Instant Run 功能的可用性。修复是禁用即时运行:
Windows 和 Linux:
File -> Settings -> Build, Execution, Deployment -> Instant Run.
苹果机:
Android Studio -> Preferences -> Build, Execution, Deployment -> Instant Run.
感谢@pophus 提及这一点。
如果您使用的是黄油刀,请使用此步骤:-
如果您使用的是 2.2.0 或更高版本的新 Jack 编译器,则不需要 'android-apt' 插件,并且可以在声明编译器依赖项时将 apt 替换为 annotationProcessor。
即去掉
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
来自您的主 gradle 文件
然后删除
apply plugin: 'android-apt'
来自你的主模块文件
替换
apt 'com.jakewharton:butterknife-compiler:8.4.0'
与
annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
关于android - 运行项目时不支持的方法 : AndroidProject. getPluginGeneration(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39591531/