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
9
votes
1 answer

Nullable types in kotlin annotation processor

I'm working on annotation processor for Kotlin and because the processed elements are in Java I don't receive nullables as ? instead with a @Nullable annotation and that's fine, but I'm facing a problem with receiving null parameters in types and…
Gil Goldzweig
  • 1,809
  • 1
  • 13
  • 26
9
votes
4 answers

Can't Debug an Annotation Processor when using kapt and gradle

I'm building an annotation processor, and I recently switched from using the default annotationProcessor type to kapt, using the kotlin-kapt plugin. I was debugging my processor by using the command ./gradlew --no-daemon -Dorg.gradle.debug=true…
8
votes
3 answers

kaptGenerateStubsDebugKotlin fails on a Apple M1 Macbook (JDK 11)

I get this failure both in Android Studio and running ./gradlew assembleDebug on the command line on a new Macbook with Apple M1 Max chip. On my old Intel Mac there are no problems building the project. > Task :app:kaptGenerateStubsDebugKotlin…
Jonik
  • 80,077
  • 70
  • 264
  • 372
8
votes
2 answers

How to use KotlinPoet to get correct TypeName for PropertySpec

Using KotlinPoet, in order to generate a PropertySpec for adding properties to classes and constructors, you need a TypeName object. The TypeMirror.asTypeName() KotlinPoet function is deprecated, because it won't always work correctly for Kotlin…
M Dapp
  • 1,453
  • 16
  • 31
8
votes
3 answers

Collection contains no element matching the predicate

I'm using the Room library, and I'm getting the following error message when I try to build the app: e: [kapt] An exception occurred: java.util.NoSuchElementException: Collection contains no element matching the predicate. Here is a more detailed…
Raj Narayanan
  • 2,443
  • 4
  • 24
  • 43
8
votes
1 answer

How to change kapt plugin generate output dir path?

I try to use kapt and vertx-Codegen to generate my service.But the output path is /build/generated/source/kapt/main/. I want /src/main/generated/. Config the build.gradle.kts,I find generate adoc to /src/main/generated/,but other files no…
EchoCow
  • 163
  • 8
8
votes
1 answer

Error: Cannot change attributes of configuration ':android:kapt' after it has been resolved when update Android Studio to 3.2

Today I updated Android Studio to 3.2 and got this error: Cannot change attributes of configuration ':android:kapt' after it has been resolved I've tried searching a few similar errors to "cannot change attritubtes of configuration...after it has…
Jay N
  • 348
  • 3
  • 11
8
votes
1 answer

Long gradle build time - Android

I have a project which is a multi-module one. I uses kotlin + dagger 2 + databindingv2. Uses the latest 3.2 android studio. But whenever I execute incremental build by changing something in one module, some other module's (no dependency with…
7
votes
1 answer

A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptWithoutKotlincTask$KaptExecutionWorkAction?java.lang.reflect.Invocation?

when I run android application in real device I am getting following gradle errors Execution failed for task ':common:kaptDebugKotlin'. > A failure occurred while executing…
Edgar
  • 860
  • 1
  • 17
  • 38
7
votes
5 answers

java.lang.reflect.InvocationTargetException (no error message) for task ':app:kaptDebugKotlin'

i ran into following error an cannot find an solution. Execution failed for task ':app:kaptDebugKotlin'. > A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution > java.lang.reflect.InvocationTargetException (no…
Padder
  • 105
  • 1
  • 1
  • 9
7
votes
1 answer

Kotlin Multiplatform Annotation Processing

Annotation Processing in Kotlin Multiplatform can be done with kapt when one has a jvm target. But how does one process annotations if there is no jvm target? Specifically I want to generate code when processing annotations from commonMain. But I…
7
votes
3 answers

Invalid Method Declaration in Kotlin Enum Class building with gradle wrapper

I have the following Kotlin enum class: enum class DurationModifier { GreaterThan { override val displayName = "≥" }, LessThan { override val displayName = "≤" }; abstract val displayName: String } It has been…
Jordan
  • 4,133
  • 1
  • 27
  • 43
7
votes
0 answers

kaptKotlin gradle task fails on JDK 11

FAILURE: Build failed with an exception. What went wrong: Execution failed for task ':module:kaptKotlin'. Could not find tools.jar in system classpath, which is required for kapt to work
7
votes
1 answer

How to use kapt from command line (with kotlinc)?

Official documentation instructs how to use kapt from Gradle and Maven. But how can I use kapt from command line, with kotlinc?
cubuspl42
  • 7,833
  • 4
  • 41
  • 65
7
votes
2 answers

Configuring kapt to process lombok annotations

This is a followup for these questions: Kotlin doesn't see Java Lombok accessors? Is kapt supported in maven? It seems that the kapt has evolved since and now it is even supported in Maven. I am trying this (note the Lombok annotation processor in…
Vojtěch
  • 11,312
  • 31
  • 103
  • 173
1 2
3
18 19