android - 运行项目时不支持的方法 : AndroidProject. getPluginGeneration()

标签 android android-studio android-studio-2.2

我正在尝试使用 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.

enter image description here

感谢@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/

相关文章:

android - 为什么我的 SoundPool 是静音的?

android-studio - 如何在 Android Studio 中显示行号

android - 如何在 android studio 中创建自己的 gradle 依赖项?

Android Studio 继续获得 Unsupported major.minor 版本 52.0

android - 是否可以在蓝图模式下使用 ConstraintLayout 滚动 ScrollView?

java - Android Studio 的构建、清理问题

android - 如何处理 fragments backstack 变化?

android - 如何在xml动画文件中指定fromXType属性

android - 调用方 Activity 的 ondestroy() 是否总是在被调用 Activity 的 oncreate() 之后被调用,还是有异常(exception)?

安卓工作室。导入后未指定模块