且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

不支持的方法异常 Android Studio 2.2

更新时间:2022-05-07 22:59:32

这里有一些解决您问题的方法.禁用Instant run应该就够了

Here are some solutions for your problem. Disabling Instant run should be enough

转到您的 build.gradle 文件并将 gradle-plugin 版本更改为:

Go to your build.gradle file and change gradle-plugin version to:

dependencies {
    classpath 'com.android.tools.build:gradle:2.2.0'
}

即时运行

这是由 Android Studio 检查 Instant Run 功能的可用性引起的.

Instant Run

It is caused by Android Studio checking availability of the Instant Run feature.

通过禁用即时运行来修复它.前往:

Fix it by disabling Instant Run. Go to:

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

取消选中所有位置

这个问题也可能是因为使用了这个插件.

This problem may be caused also by using this plugin.

我想在这个例子中你正在使用 Butterknife 库.....

I suppose for this example that you're using Butterknife library.....

注意:如果您使用的是版本 2.2.0 的新 Jack 编译器或更新,你不需要 'android-apt' 插件,而是可以声明编译器时用 annotationProcessor 替换 apt依赖.

NOTE: 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.

转到您的 build.gradle 文件并删除:

Go to your build.gradle file and remove:

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

然后转到您的 app/build.gradle 文件并删除:

Then go to your app/build.gradle file and remove:

apply plugin: 'android-apt'

然后在同一个文件中,替换现有的:

Then in the same file, replace existing:

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

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

现在应该可以了