8

i got this error Error:android-apt plugin is incompatible with the Android Gradle plugin. Please use 'annotationProcessor' configuration instead. when i am adding butterknife is ther any thing wrong i am doing with dependency adding what dependancy should i use for latest android studio

build.gradle(module:app) file below

apply plugin: 'com.android.application'
apply plugin: 'android-apt'
android {
    compileSdkVersion 26
    buildToolsVersion '26.0.2'
    defaultConfig {
        applicationId "com.example.sony.welcomefilemanager"
        minSdkVersion 16
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation 'com.android.support:support-v4:26.1.0'
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:26.+'
    compile 'com.android.support:design:26.+'
    compile 'com.android.support:support-vector-drawable:26.+'
    compile 'com.android.support:design:26+'
    compile 'com.android.support:recyclerview-v7:26+'
    compile 'com.android.support:cardview-v7:26.+'
    compile 'com.jakewharton:butterknife:7.0.1'
    apt 'com.jakewharton:butterknife-compiler:8.0.1'
    testCompile 'junit:junit:4.12'
}

build.gradle(project) file below

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0'
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
        google()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
Yogesh Marathe
  • 99
  • 1
  • 1
  • 6

3 Answers3

13

The android-apt plugin has been deprecated.

As of the Android Gradle plugin version 2.2, all functionality that was previously provided by android-apt is now available in the Android plugin.

  • Make sure you are on the Android Gradle 2.2 plugin or newer.
  • Remove the android-apt plugin from your build scripts
  • Change all (if any) apt, androidTestApt and testApt dependencies to their new format
Community
  • 1
  • 1
MrJM
  • 1,214
  • 1
  • 12
  • 26
  • And change `apt`, `androidTestApt`, `testApt` into: `dependencies { compile 'com.google.dagger:dagger:2.0' annotationProcessor 'com.google.dagger:dagger-compiler:2.0' }` – Duong.Nguyen Mar 25 '21 at 02:24
5
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
android {
    compileSdkVersion 26
    buildToolsVersion '26.0.2'
    defaultConfig {

Delete from gradle apply plugin: 'android-apt'

Like this

apply plugin: 'com.android.application'
android {
    compileSdkVersion 26
    buildToolsVersion '26.0.2'
    defaultConfig {
Ravi Patel
  • 309
  • 2
  • 13
1

I had this apply plugin: 'com.neenbedankt.android-apt' in build.gradle (app module) file and just removed it and the error was fixed.

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