不支持的方法:运行项目时的 AndroidProject.getPluginGeneration() [英] Unsupported method: AndroidProject.getPluginGeneration() while running project

查看:14
本文介绍了不支持的方法:运行项目时的 AndroidProject.getPluginGeneration()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Android Studio 2.2 运行我的项目,但出现此错误

I'm trying to run my Project with Android Studio 2.2 but I get this error

Unsupported method: AndroidProject.getPluginGeneration().
The version of Gradle you connect to does not support that method.

我使用的是 ButterKnife 8.4.0

I am using ButterKnife 8.4.0

我的应用程序 gradle.file:

My app 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文件:

My module gradle file:

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'
}

为什么它不起作用,我该如何解决?

Why does it not work and how do I solve it?

推荐答案

一般问题:-

这可能是因为 AS 正在检查 Instant Run 功能的可用性.修复的是禁用即时运行:

It can occur because AS was checking availability of the Instant Run feature. The fixed is to disable Instant Run:

Windows &Linux:

File -> Settings -> Build, Execution, Deployment -> Instant Run.

苹果机:

Android Studio -> Preferences -> Build, Execution, Deployment -> Instant Run.

感谢@pophus 提到这一点.

Thanks to @pophus for mentioning this.

使用此步骤如果您使用的是黄油刀:-

如果您使用 2.2.0 或更高版本的新 Jack 编译器,则不需要 'android-apt' 插件,而是可以在声明编译器依赖项时将 apt 替换为 annotationProcessor.

If you are using the new Jack compiler with version 2.2.0 or newer, you do not need the 'android-apt' plugin and can instead replace apt with annotationProcessor when declaring the compiler dependency.

即删除

classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'

来自你的主 gradle 文件

from your main gradle file

并删除

apply plugin: 'android-apt'

来自你的主模块文件

并替换

apt 'com.jakewharton:butterknife-compiler:8.4.0'

annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'

这篇关于不支持的方法:运行项目时的 AndroidProject.getPluginGeneration()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆