Original kapt is deprecated

喜你入骨 提交于 2019-12-14 03:43:46

问题


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?


回答1:


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.




回答2:


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



回答3:


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'



回答4:


apply plugin: 'kotlin-kapt'

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



回答5:


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"



来源:https://stackoverflow.com/questions/49134860/original-kapt-is-deprecated

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!