Bhuvanesh BS
Bhuvanesh BS

Reputation: 13617

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?

Upvotes: 19

Views: 45024

Answers (11)

Raunaq Kalra
Raunaq Kalra

Reputation: 31

This worked for me on the latest version.

Add the below code in the app-level build.gradle

plugins {
    id("com.android.application")
    id("org.jetbrains.kotlin.android")
    id ("kotlin-kapt")
}

Upvotes: 2

Ashraf Gardizy
Ashraf Gardizy

Reputation: 389

Add the following code snipet in your Gradle module file: I had the same problem and it worked for me after syncing the project.

plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'kotlin-kapt'
}

Upvotes: 1

Vikrant Singh Rawat
Vikrant Singh Rawat

Reputation: 109

Added in app level gradel file like this.

plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'kotlin-kapt'}

Upvotes: 1

pasan wedikkara
pasan wedikkara

Reputation: 1

def room_version = "2.5.0"
implementation("androidx.room:room-runtime:$room_version")

you must use this in dependencies

    // To use Kotlin annotation processing tool (kapt)
    kapt("androidx.room:room-compiler:$room_version")
    // To use Kotlin Symbol Processing (KSP)

    // optional - Kotlin Extensions and Coroutines support for Room
    implementation("androidx.room:room-ktx:$room_version")
    
    // optional - Test helpers
    testImplementation("androidx.room:room-testing:$room_version")

and befeore that add this into

plugins {
    
    id 'kotlin-kapt'
}

Upvotes: 0

Abbas Khan Waliullahi
Abbas Khan Waliullahi

Reputation: 345

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

Upvotes: 8

// add following line in build.gradle(Module:app) file at the end of plugin section

apply plugin: 'kotlin-kapt'

Upvotes: 0

Actually the real problem is in the order of lines i was also wasted time in it finally i figure out this try like this you will get rid from this

apply plugin: 'realm-android'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

apply plugin: 'kotlin-kapt'

kapt "com.android.databinding:compiler:3.1.4"

Upvotes: -3

indrajeet jyoti
indrajeet jyoti

Reputation: 431

apply plugin: 'kotlin-kapt'

// add these line in the bulid.gradle(app) module in the top

Upvotes: 1

Zohab Ali
Zohab Ali

Reputation: 9564

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'

Upvotes: 7

Raja
Raja

Reputation: 2815

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.

Upvotes: 47

Bhuvanesh BS
Bhuvanesh BS

Reputation: 13617

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 {
      ........
    }
}

Upvotes: 14

Related Questions