49 questions
-1
votes
1
answer
30
views
Why does gradle fail with "[ksp] No providers found in processor classpath." after KSP migration?
I am currently undergoing the KSP migration in my android app, to get rid of annotationProcessor and kapt
See also this doc
I have included the plugin in the root gradle an in all module gradle files ...
2
votes
1
answer
61
views
Is it possible to get instance of an kotlin object to invoke its method in compile time during KSP phase?
I am creating a library that scans various annotations and takes actions based on them which is a standard use case of KSP (Kotlin Symbol Processing).
The non-standard thing is the fact that the user ...
1
vote
2
answers
371
views
What should I do if the files generated by KSP are frequently being automatically deleted?
I'm trying to use KSP to process annotations and generate some code, but I'm encountering a problem. When I modify the upstream code, the downstream module's code doesn't trigger a compilation, and ...
60
votes
3
answers
16k
views
Issue: java.lang.IllegalStateException: Storage for [...] is already registered When Adding Type Converters with KSP
Overview:
When working with Room and KSP (Kotlin Symbol Processing) for type converters in an Android project, I encountered a recurring issue after adding a new type converter. The error message was:
...
0
votes
2
answers
565
views
KSP library for room
I want to use the room library for database, when I add the room library to my project, I can easily use it and I have no problem, but in order to be able to use room properly, I must I use ksp, well, ...
2
votes
1
answer
226
views
KSP2 throwing NPE during build
I am using Room with KSP, which is giving this error during Gradle build:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':shared:kspCommonMainKotlinMetadata'.
at org....
3
votes
1
answer
5k
views
Migrating to Kotlin 2.0 causes error with KSP
After migrating to Kotlin 2.0, when I sync the project with the gradle files no issues arise. However, when I try to deploy to the device, I get the following error:
> Task :app:kspDebugKotlin ...
1
vote
0
answers
141
views
Android room dao generation fails afrer Migrating to ksp from kapt due to TypeAlias
I have migrated from kapt to ksp for my current android project.
All my dao(s) extend a base dao that is defined as a kotlin typealias as follows:-
typealias BaseDao<T> = AbstractDao<T, Long&...
4
votes
4
answers
7k
views
Unable to enable ksp for room database when using kotlin DSL build script
Problem: I want to use ksp with room. On adding ksp(libs.androidx.room.compiler) in the module level build.gradle.kts file, I get the following error:
Unable to load class 'org.jetbrains.kotlin....
2
votes
1
answer
2k
views
Migrating Room from KAPT to KSP leads to RuntimeException
My DB was all right before it, I migrated from KAPT to KSP as follows documentation (https://developer.android.com/build/migrate-to-ksp), it worked fine for Hilt library, but when I change Room ...
2
votes
1
answer
750
views
Kotlin Multiplatform generated code is not aware of target's code
I've a KMP shared module that imports a KSP library to generate code for iOS targets, and it works as expected:
However, I’m facing a strange behavior; my generated code cannot see/access what’s in ...
1
vote
1
answer
798
views
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] [...
3
votes
0
answers
1k
views
Control output folder and source set for a KSP annotation processor
In an Android project (native with mixed java / kotlin) we are using a KSP based annotation processor to collect class definitions that are annotated with a specific project internal annotation. All ...
1
vote
1
answer
451
views
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 ...
2
votes
2
answers
2k
views
How to set --verbose in IntelliJ (Android Studio) for KSP debugging purposes?
As shared in https://stackoverflow.com/a/75441869/3286489, we have a way to print log out for KSP compilation.
However, the print out only shows WARNING and ERROR. If I want to have INFO, I'll need to ...
29
votes
5
answers
40k
views
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 ...
1
vote
1
answer
815
views
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 ...
6
votes
1
answer
1k
views
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 ...
1
vote
1
answer
1k
views
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,...
0
votes
1
answer
3k
views
How to use Kotlin Symbol Processing (KSP) to populate an existing list
I've been playing recently with KSP and have managed to develop interesting capabilities (such as automatic recyclerview and view holder generators based on their layout id), and so far all is well.
...
1
vote
1
answer
618
views
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 ...
0
votes
1
answer
1k
views
How to determine if a functions return type is a primitive in ksp
Short version: How can I tell if a KSType is a primitive or even compare it to a kotlin type?
I'm writing a code generator in Kotlin using ksp. I am iterating through a type's functions and have a ...
0
votes
1
answer
2k
views
KSP on Kotlin Multiplatform fails on the kspJs with "Collection has more than one element."
I'm experimenting with KSP (Kotlin Symbol Processing) to see what it's capable of and I'm trying to get it working on a Kotlin Multiplatform project.
When I only enable kspJvm, it works perfectly, as ...
0
votes
0
answers
531
views
How to add one parameter for a function using kotlin symbol processing(KSP)
I have an annotation "AddHeader" for functions:
annotation class AddHeader
If one function adds this annotation, it will add a parameter like this:
// service for retrofit
interface ...
0
votes
1
answer
361
views
What does "Symbol" mean in KSP
Currently I am studying on KSP(Kotlin Symbol Processing), and I am curious about what does "Symbol" mean in KSP.
When it comes to comparing with KAPT, it says "To run Java annotation ...