Questions tagged [kapt]

Use this tag for questions about the kapt (Kotlin Annotation Processing) compiler plugin for annotation processing with Kotlin.

From Kotlin reference:

Annotation processors (see JSR 269) are supported in Kotlin with the kapt compiler plugin.

Being short, you can use libraries such as Dagger or Data Binding in your Kotlin projects.

282 questions
111
votes
31 answers

Room "Not sure how to convert a Cursor to this method's return type": which method?

Error:Not sure how to convert a Cursor to this method's return type Error:Execution failed for task ':app:compileDebugJavaWithJavac'. Compilation failed; see the compiler error output for details. Using Room I'm getting this error and I'd like to…
106
votes
9 answers

Gradle DSL method not found: 'kapt()'

Gradle DSL method not found: 'kapt()' Possible causes: The project 'jetpacklearn' may be using a version of the Android Gradle plug-in that does not contain the method (e.g. 'testCompile' was added in 1.1.0). Upgrade plugin to version 3.4.0 and sync…
cheng zhang
  • 1,081
  • 2
  • 7
  • 3
58
votes
6 answers

Android Room Persistence library and Kotlin

I am trying to write a simple app using Kotlin and Room Persistence Library. I followed the tutorial in the Android Persistence codelab. Here is my AppDatabase class in Kotlin: @Database(entities = arrayOf(User::class), version = 1) abstract class…
Thanh Pham
  • 698
  • 1
  • 6
  • 10
51
votes
3 answers

warning : The following options were not recognized by any processor: '[dagger.fastInit, kapt.kotlin.generated]'

I get this warning when I try to run or build an app in Android Studio. Why am I getting this? Do I need to heed this warning? The following options were not recognized by any processor: '[dagger.fastInit, kapt.kotlin.generated]'
Bincy Baby
  • 3,941
  • 5
  • 36
  • 62
39
votes
2 answers

Android project with Java and Kotlin files, kapt or annotationProcessor?

I would like to know if in an Android project mixing Java and Kotlin files we must use annotationProcessor or kapt, or both ? In my understanding annotationProcessor must be used for Java files using annotations for code generation, and kapt must…
gxela
  • 703
  • 1
  • 6
  • 14
32
votes
7 answers

java.lang.IllegalAccessError: class org.jetbrains.kotlin.kapt3.base.KaptContext Android

I've been getting an error like this for days, but I couldn't find a solution. Can you please help me? What could the problem be caused by? Error : java.lang.IllegalAccessError: class org.jetbrains.kotlin.kapt3.base.KaptContext (in unnamed module…
Nisa Efendioglu
  • 901
  • 3
  • 12
  • 22
32
votes
1 answer

how to use kapt in androidTest scope

Is there a way to use kapt for the androidtest scope? Currently I am migrating from com.neenbedankt.gradle.plugins android-apt to kapt - which works fine - but I am not sure how to do it for the androidTest scope - so replacing: apt…
ligi
  • 39,001
  • 44
  • 144
  • 244
28
votes
2 answers

Databinding annotation processor kapt warning

In my app module's build.gradle, I have added dependencies { kapt('com.android.databinding:compiler:3.1.2') ... } but I'm still receiving the compiler warning for app: 'annotationProcessor' dependencies won't be recognized as kapt annotation…
cren90
  • 1,367
  • 2
  • 17
  • 30
27
votes
5 answers

Kapt is not working properly with OpenJDK 16

I have an application that uses Kotlin 1.5.0 and Kapt for mapstructs. I have updated my JDK to 16 and I get the following compilation error: Failed to execute goal org.jetbrains.kotlin:kotlin-maven-plugin:1.5.0:kapt (kapt) on project X: Compilation…
Nico
  • 858
  • 2
  • 11
  • 27
27
votes
4 answers

Could not find method kapt() for Glide

apply plugin: 'com.google.gms.google-services' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' apply plugin: 'kotlin-kapt' classpath 'com.android.tools.build:gradle:3.2.0' classpath…
Rajas47Ashtikar
  • 583
  • 2
  • 6
  • 11
24
votes
5 answers

Current JDK version 1.8 has a bug that prevents Room from being incremental

We're trying to improve the build times of our multi-module Android app and we've reached the point where we tried to enable incremental KAPT annotation processing compilation. Android Studio version: v3.5.2 Room version: v2.2.1 Gradle version:…
Bogdan Zurac
  • 6,348
  • 11
  • 48
  • 96
23
votes
10 answers

Build Error: 'kspDebugKotlin' task (current target is 17)

Execution failed for task ':app:kspDebugKotlin'. Unable to build with ksp 'compileDebugJavaWithJavac' task (current target is 1.8) and 'kspDebugKotlin' task (current target is 17) jvm target compatibility should be set to the same Java…
Sohaib Ahmed
  • 1,990
  • 1
  • 5
  • 23
22
votes
2 answers

Kapt annotation processing - how to show full stacktrace

I am working on a android project using Kotlin, Databinding and Room. Sometimes the build fails with a error message, containing no information about what exactly went wrong, except that it has something to do with the annotation processor (which…
tarbos
  • 241
  • 1
  • 2
  • 6
21
votes
7 answers

kapt Build Fails With Dagger Android Processor

I am attempting to include the Dagger Android Processor (documented here) in my project with the Kotlin Annotation Processing Tool (kapt). I have included the proper dependencies in my build.gradle file: apply plugin: 'com.android.application' apply…
Bryan
  • 14,756
  • 10
  • 70
  • 125
17
votes
2 answers

Using kapt with multiplatform subproject

I have the following project structure root-project │ build.gradle.kts │ └───multiplatform-project │ │ build.gradle.kts │ │ │ └───src │ │ kotlin | | js │ └───simple-kotlin-project │ build.gradle.kts So there are…
1
2 3
18 19