105

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.

I am using ButterKnife 8.4.0

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

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?

JAAD
  • 12,349
  • 7
  • 36
  • 57

7 Answers7

281

General Issue:-

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.

Mac:

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

enter image description here

Thanks to @pophus for mentioning this.

Use this Steps If you are using a butterknife:-

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.

That is, remove

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

from your main gradle file

And remove

apply plugin: 'android-apt'

from your main module file

and replace

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

with

annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
Kaushik
  • 6,150
  • 5
  • 39
  • 54
JAAD
  • 12,349
  • 7
  • 36
  • 57
  • I want to love instant run but it breaks things in such odd ways that it makes it impossible to use regularly without quite the time investment – Allison Nov 27 '16 at 19:24
24

I encountered this error in Android Studio 2.2, in my case it was cause by AS checking availability of the Instant Run feature. I fixed it by disabling Instant Run:

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

pophus
  • 240
  • 2
  • 4
  • Worked for my colleague. He was on gradle 1.2.3 – gitter Sep 21 '16 at 06:12
  • 1
    You saved my life. I'm working on a project close to release and I don't want to upgrade gradle for it. This fix/workaround definitely helped. – Better Shao Sep 21 '16 at 06:27
  • @pophus it can occur due to different reason maybe instant run is one, I encountered this issue with butterknife – JAAD Sep 21 '16 at 06:53
7

Change gradle version to 2.2

dependencies {
    classpath 'com.android.tools.build:gradle:2.2.0'
}
Sayem
  • 4,891
  • 3
  • 28
  • 43
  • sorry that was a typo i am infact using 2.2.0 – JAAD Sep 20 '16 at 10:46
  • then try by deleting your .idea folder & restart your ide. After project update to 2.2 I also faced different problems. One solution i found is to delete .idea folder. Now all are working fine. – Sayem Sep 20 '16 at 10:52
6

On Windows it is

File / Settings/ Build, Execution, Deployment / Instant Run.

Uncheck Enable Instant Run to hot swap code...

Flot2011
  • 4,601
  • 3
  • 44
  • 61
  • 1
    your answer doesn't add anything new, it has been already stated in other answers , can you clarify? – JAAD Dec 02 '16 at 05:38
  • 1
    It took me some time to find this option on Windows, so I wanted to save for others this time. As simple as that – Flot2011 Dec 04 '16 at 02:02
2

just close instant run

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

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

Michael
  • 53
  • 1
  • 3
    your answer doesn't add anything new, it has been already stated in other answers , can you clarify? – JAAD Dec 02 '16 at 05:39
2

I ran in the same error on a very old project. Since Android Studio 3.5 does not have the Instant Run Option anymore, I required a different solution.

It turned out, that I had to change the gradle version manually in the Project Settings. I used the version a New Project would use automatically, since the dropdowns were empty.

In my case, it was Plugin Version 3.5.1 and Gradle Version 5.4.1.

After that I started a Build - Clean Project and everything turned out fine.

Gunnar Bernstein
  • 6,074
  • 2
  • 45
  • 67
1

Just upgrade the Gradle plugin version to the last version :

dependencies {
        classpath 'com.android.tools.build:gradle:3.5.1'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }

and be sure your Gradle is the last v too :

#Sun Nov 03 16:47:32 IRST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip

NOTE: use google in repository too

Sana Ebadi
  • 6,656
  • 2
  • 44
  • 44