Questions tagged [kotlin-symbol-processing]

The Kotlin Symbol Processing API (KSP) allows to write code that is executed when compiling a Kotlin application. Use this tag in questions about the Kotlin Symbol Processing API and writing symbol processors.

The documentation describes the Kotlin Symbol Processing like this:

Kotlin Symbol Processing (KSP) is an API that you can use to develop lightweight compiler plugins. KSP provides a simplified compiler plugin API that leverages the power of Kotlin while keeping the learning curve at a minimum.

See the quickstart guide and the official documentation for information on how to write symbol processors.

A sample project can be found here.

28 questions
17
votes
1 answer

Provide annotation processor argument when using Kotlin Signal Processing (KSP)

I used the following to use KSP in combination with Room: plugins { id 'com.google.devtools.ksp' version "$kotlin_version-1.0.0" dependencies { ksp "androidx.room:room-compiler:$room_version" And this actually works. However, when I try to…
Cristan
  • 12,083
  • 7
  • 65
  • 69
13
votes
4 answers

Could not find method ksp() for arguments

I just started learning about Android in Kotlin and I was creating a note application just for learning purposes. I wanted to use Room to store saved notes in my database, so i was checking out the developer.android tutorials and We have some …
Achintya
  • 137
  • 1
  • 6
12
votes
2 answers

Kapt to KSP migration errors

I am getting an error message when I try to migrate an android project using kapt to KSP. Error message Unable to find method ''void org.jetbrains.kotlin.gradle.tasks.KotlinCompile.(org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptions)'' 'void…
Abhimanyu
  • 11,351
  • 7
  • 51
  • 121
5
votes
1 answer

Debug Kotlin Symbol Processing (KSP)

How to debug KSP using Idea and Gradle? Running build task from IDE in debug mode does not attach IDE to the process. Is there any command-line way to make the processor wait until IDE attach to thte process? (I'm using KSP 1.5.31-1.0.0)
Max Farsikov
  • 2,451
  • 19
  • 25
4
votes
1 answer

KSP: how can I get the default value of a data class property?

I have the following data class annotated with @MyAnnotation: @MyAnnotation data class MyDataClass( val foo: Boolean = true, val bar: Int = 123, val buz: String? = "abc", ) From the ClassDeclaration I can get all the…
4
votes
3 answers

Android Room in Kotlin 1.7.0

When updating to Kotlin 1.7.0, since it's required by the latest version of Jetpack Compose, I found out that Room was no longer working. I was using kapt as my annotation processor, and the compiler was throwing error messages such as: [*] error:…
Arnyminer Z
  • 5,784
  • 5
  • 18
  • 32
4
votes
2 answers

Kotlin KSP annotation Processor generated class not found during jupiter test

I'm developing an KSP annotation processor for Kotlin. The code is generated correctly during the compile time and I can see the generated classes in the output directory. Now I want to test my annotation processor via JUnit and…
Jayser
  • 371
  • 4
  • 15
1
vote
2 answers

How to correctly add Room Persistence dependencies to my Jetack Compose Android app

I have been struggling to add Room dependencies for a couple of days now(not proud). There is always an error no matter what i try. I am not the most experienced though. I added the below from the Android docs site. `val room_version =…
1
vote
1 answer

Modify Kotlin compiled code output based on annotation (not generate separate code)

Is there a way to create a Kotlin compiler plugin that can modify the code being written? I don't want to create separate generated code but actually modify the code itself. For example, given this source: Original @Composable fun MyScreen() { …
Samuel Neff
  • 73,278
  • 17
  • 138
  • 182
1
vote
1 answer

How to print a log in Kotlin KSP Processor?

In Kotlin KSP, I try to debug the processor internal class ListedProcessor( private val fileGenerator: FileWriter, ) : SymbolProcessor { override fun process(resolver: Resolver): List { val listedFunctions:…
Elye
  • 53,639
  • 54
  • 212
  • 474
1
vote
1 answer

Kotlin KSP generated source not found during CI build

I have a problem with KSP source code generation only during CI build event. It always work in my local machine. This is the link to the error for travis build. What is the mistake in my config or source files here? This is the link to github…
Mirjalal
  • 1,292
  • 1
  • 17
  • 40
1
vote
1 answer

How to generate android resource (xml) files by using Kotlin KSP

I'm working on a custom generator to generate code from annotation on Android platform. I currently using KSP for code generating. After I generate the code, I need to generate some resource xml files, What shall I do for it? I considered some…
1
vote
1 answer

How do I add KSP plugin to android project gradle?

My aim is to add the KSP plugin to gradle as stated in the question heading. just go through the line below each //from quickstart comments and you'll see all the error origins. To add the dependencies I referred the Kotlin KSP quickstart…
1
vote
1 answer

KSP Room processor fails on CI machine

I've migrated Room kapt to ksp. Everything works fine on the local machine (Mac), but on our Linux CI machine I'm getting an error, and the app does not compile. Any ideas, why it might happen and how to fix it? Stacktrace: Task…
0
votes
1 answer

Android Compose doesn't work with KSP, ROOM for multi-module projects

I noticed after enabling Android Compose for the project: buildFeatures { compose true } KSP with ROOM doesn't work properly finishing with exceptions like this during bulding project: [ksp] [MissingType]: Element…
1
2