Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Original kapt is deprecated

I have changed Kotlin version to 1.2.30. After the update I unable to run the project. I got the below error message.

Error:Execution failed for task ':app:compileDevDebugJavaWithJavac'.
> app: Original kapt is deprecated. Please add "apply plugin: 'kotlin-kapt'" to your build.gradle.

How do I resolve this?

like image 895
Bhuvanesh BS Avatar asked Mar 06 '18 15:03

Bhuvanesh BS


4 Answers

Source: Annotation Processing with Kotlin

Source Link 1: https://kotlinlang.org/docs/reference/kapt.html

Source Link 2:https://github.com/uber/NullAway/issues/75

Kotlin plugin doesn't pick up annotationProcessor dependencies, So we have to use kapt dependencies with kotlin-kapt.

Use the latest version of Kotlin annotation processor put this line at top of your module's level build.gradle file

apply plugin: 'kotlin-kapt'

Like

apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'  // add this line

android {
    compileSdkVersion 27
    defaultConfig {
      ........
    }
}

Don't forget to update the version when you use different build plugin version.

like image 179
Raja Avatar answered Sep 23 '22 08:09

Raja


Add kotlin-kapt plugin in your app-level build.gradle file.

Update your gradle like this:

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'  // add this line

android {
    compileSdkVersion 27
    defaultConfig {
      ........
    }
}
like image 45
Bhuvanesh BS Avatar answered Sep 23 '22 08:09

Bhuvanesh BS


I was getting this error after adding apply plugin: 'realm-android' so the problem was the order of statements. This order worked for me

apply plugin: 'realm-android'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
like image 35
Zohab Ali Avatar answered Sep 20 '22 08:09

Zohab Ali


open your app level gradle file and add this line like this shown in the image and sync you are good to go..

enter image description here

like image 27
Abbas Khan Waliullahi Avatar answered Sep 20 '22 08:09

Abbas Khan Waliullahi