https://kotlinlang.org logo
Join Slack
Powered by
# ksp
  • s

    Sha Sha Chu

    07/24/2025, 6:05 PM
    hi all, we have had an intermittent issue to do with multiple round processing and I'm looking for tips to debug. We use Hilt, and we sometimes inject classes which are generated from an internal ksp processor. every so often, Hilt fails to find the generated class, and I don't know whether it's a bug in Hilt with not correctly deferring the type, a bug in ksp where it's incorrectly reaching the terminal condition, or our processor where it may sometimes fail to run. any suggestions?
    y
    d
    • 3
    • 4
  • a

    alexey.andreev

    07/30/2025, 6:22 AM
    Is it possible to read/depend on non-Kotlin files? E.g.
    properties
    files in
    src/main/resources
    ?
    h
    • 2
    • 1
  • s

    sindrenm

    07/31/2025, 8:00 AM
    Time for a 2.2.20-Beta2-2.0.2 release? 🙏
    z
    • 2
    • 3
  • r

    ritesh

    08/01/2025, 5:29 AM
    Do we need support from epoxy before migrating the project to k-2.2.20? More in thread
    ✅ 1
    • 1
    • 3
  • a

    Alexander Ioffe

    08/04/2025, 4:07 AM
    Question on the KSP documentation here. The documentation seems to indicate that if you want KSP processing to be done in a KMP project on (for example) both commonMain and jvmMain you use the following configuration:
    Copy code
    kotlin {
        jvm()
        ...
        sourceSets {
            val commonMain by getting { ... }
            val jvmMain by getting { ... }
        }
    }
    
    dependencies {
        add("kspCommonMainMetadata", project(":my-processor"))
        add("kspJvm", project(":my-processor"))
    }
    In practice however, this seems to blow up my build by generating the same code in commonMain twice! The first time in
    MyProject/build/generated/ksp/metadata/commonMain/kotlin
    and the second in
    MyProject/build/generated/ksp/jvm/jvmMain/kotlin
    . Now to be fair, if I have some class in jvmMain it will only appear in the latter location but why is everything from the commonMain directory also there???
  • h

    Hakan Mehmed

    08/04/2025, 8:36 PM
    Hi everyone, I am reposting here what is already in ksp github page readme as of today:
    Copy code
    Deprecation notice for KSP1
    KSP1 is deprecated and support will be removed. We are focusing our development efforts on KSP2 to provide better performance, improved APIs, and a more robust architecture for the future.
    
    Compatibility Limitations
    Please be aware that KSP1 will not be updated to support upcoming major versions of the Android and Kotlin toolchains. Specifically, KSP1 will not be compatible with:
    
    Kotlin version 2.3.0 and higher.
    Android Gradle Plugin (AGP) version 9.0 and higher.
    Projects using KSP1 may not behave correctly (or fail the build) if you upgrade to these or any subsequent versions of AGP or Kotlin.
    
    To ensure your annotation processors continue to function correctly and to take advantage of future tooling advancements, it is crucial to migrate your projects to use KSP2 (which has been the default since beginning of 2025)
    Support for KSP1 is expected to be removed by end of 2025 (possibly even earlier) If there are any bugs in KSP2 that are total blockers for the migration to it, please let us know
    👍 1
    e
    g
    +2
    • 5
    • 6
  • s

    scana

    08/05/2025, 6:02 PM
    Has anyone seen an issue like the following with Kotlin 2.2 / KSP 2.2.0-2.0.2? / KSP2 enabled?
    Copy code
    > A failure occurred while executing com.google.devtools.ksp.gradle.KspAAWorkerAction
       > Error while resolving ksp.org.jetbrains.kotlin.fir.declarations.impl.FirRegularClassImpl 
         from RAW_FIR to STATUS
         current declaration phase STATUS
         origin: Source
         session: class ksp.org.jetbrains.kotlin.analysis.low.level.api.fir.sessions.LLFirSourcesSession (Kotlin reflection is not available)
         module data: class ksp.org.jetbrains.kotlin.analysis.low.level.api.fir.projectStructure.LLFirModuleData (Kotlin reflection is not available)
         KaModule: class ksp.org.jetbrains.kotlin.analysis.project.structure.impl.KaSourceModuleImpl (Kotlin reflection is not available)
         platform: JVM (21)
    j
    t
    • 3
    • 9
  • s

    Sandeep Dhami

    08/06/2025, 12:07 PM
    Hey everyone, I’m facing an issue where KSP fails to resolve types in Kotlin Multiplatform (Android/iOS) targets when using kotlin-inject 0.8.0. The types are declared in commonMain, but during iOS compilation (kspKotlinIosSimulatorArm64), KSP throws unresolved type errors like:
    Copy code
    Error type '<ERROR TYPE: PlatformResourcesWrapper>' is not resolvable in the current round of processing.
    I’ve detailed the problem and shared a code snippet in this GitHub issue: 🔗 https://github.com/evant/kotlin-inject/issues/499 Would appreciate any guidance or workaround suggestions 🙏! CC @evant @eygraber
  • m

    micah

    08/06/2025, 5:55 PM
    Hey, everyone. I'm pretty new to KSP, but I've got a simple project up and running, and now I'm looking at testing. I think I've got a few questions: 1. Is https://github.com/tschuchortdev/kotlin-compile-testing still the goto solution to simplify testing? It's referenced in the development docs, but I don't actually see it getting used in the major ksp projects. 2. Does the advent of KSP2 have implications for testing? Is there an easier way now that KSP2 is available? Practically speaking, I don't need full end to end testing, but need enough KSP magic to go from some annotated classes to `KSClassDeclaration`s.
  • r

    rnett

    08/09/2025, 5:50 AM
    Hey there, in the documentation of
    KSValueArgument.value
    , it states that it may be a
    KSClassDeclaration for annotation arguments of type Enum (in this caseKSClassDeclaration.classKind equals to ClassKind.ENUM_CLASS);
    . However,
    ClassKind.ENUM_CLASS
    is used for the enclosing
    enum class
    . If this is accurate, how can you determine the entry that is the actual value of the argument? Or is the documentation just mistaken and it's actually
    ClassKind.ENUM_ENTRY
    ?
  • z

    Zach G

    08/13/2025, 11:42 PM
    If I have a generated class A which uses a class B, but I want to give the user the option to either write their own B or have B be created by my processor, is the correct way to do this to create a separate annotation which makes A's processor aware of this annotation over the class the user chooses as B, and if it is not present then generate?
    y
    a
    • 3
    • 6
  • h

    Hakan Mehmed

    08/26/2025, 8:22 PM
    Hi all, a quick note related to KSP 2.0.3
    Copy code
    KSP Gradle plugin 2.0.3 to require minimum AGP version 8.4.0+
    
    Please be aware that starting with version 2.0.3, the Kotlin Symbol Processing (KSP) Gradle plugin will introduce a new minimum requirement for the Android Gradle Plugin (AGP). To ensure your project continues to build successfully, you must use AGP version 8.4.0 or higher when using KSP 2.0.3 or any newer release. This will be a runtime requirement, meaning your builds will fail if you update KSP without also updating AGP to the required minimum version or a newer one.
    The reason for this is to allow cleaning up various runtime checks related to AGP version within KSP itself. If for any reason this version of AGP seems too new for your project using KSP, do let us know. We also plan to update the min AGP version as time progresses. :)
    👍 5
    thank you color 3
  • a

    Alexander Ioffe

    08/29/2025, 7:29 PM
    Does KSP2 have a understanding of expressions? Does it have an equivalent of
    IrCall
    ?
    🚫 2
  • l

    Lukas Anda

    08/31/2025, 3:33 PM
    Hey guys, I found an interesting issue (while using Koin annotations). In KMP, the
    resolver.getDeclarationsFromPackage
    returns the generated declarations in second pass whereas in single-target setup, it finds everything it needs in first pass. can I somehow mitigate that? I am using newest version of KSP
  • t

    Tower Guidev2

    09/04/2025, 7:53 AM
    Hi while trying to improve the build performance of my current android application in android studio i have started seeing the following ksp errors
    e: [ksp] Cannot use unbound generics in query functions. It must be bound to a type through base Dao class. - core.persistence.database.dao.AbstractDao.querySingle(androidx.sqlite.db.SupportSQLiteQuery)
    e: [ksp] Cannot use unbound generics in query functions. It must be bound to a type through base Dao class. - core.persistence.database.dao.AbstractDao.querySingleOrNull(androidx.sqlite.db.SupportSQLiteQuery)
    e: [ksp] Cannot use unbound generics in query functions. It must be bound to a type through base Dao class. - core.persistence.database.dao.AbstractDao.queryList(androidx.sqlite.db.SupportSQLiteQuery)
    e: [ksp] Type of the parameter must be a class annotated with @Entity or a collection/array of it. - obj in core.persistence.database.dao.AbstractDao.save(TEntity)
    e: [ksp] Type of the parameter must be a class annotated with @Entity or a collection/array of it. - obj in core.persistence.database.dao.AbstractDao.save(TEntity[])
    e: [ksp] Type of the parameter must be a class annotated with @Entity or a collection/array of it. - obj in core.persistence.database.dao.AbstractDao.save(java.util.ArrayList<TEntity>)
    e: [ksp] Type of the parameter must be a class annotated with @Entity or a collection/array of it. - obj in core.persistence.database.dao.AbstractDao.save(java.util.List<? extends TEntity>)
    e: [ksp] Type of the parameter must be a class annotated with @Entity or a collection/array of it. - obj in core.persistence.database.dao.AbstractDao.saveAsync(TEntity[])
    e: [ksp] Type of the parameter must be a class annotated with @Entity or a collection/array of it. - obj in core.persistence.database.dao.AbstractDao.saveAndReturnId(TEntity)
    e: [ksp] Type of the parameter must be a class annotated with @Entity or a collection/array of it. - obj in core.persistence.database.dao.AbstractDao.saveAll(TEntity)
    e: [ksp] Type of the parameter must be a class annotated with @Entity or a collection/array of it. - obj in core.persistence.database.dao.AbstractDao.saveAll(TEntity[])
    e: [ksp] Type of the parameter must be a class annotated with @Entity or a collection/array of it. - obj in core.persistence.database.dao.AbstractDao.delete(TEntity)
    e: [ksp] Type of the parameter must be a class annotated with @Entity or a collection/array of it. - obj in core.persistence.database.dao.AbstractDao.deleteAsync(TEntity)
    e: [ksp] Type of the parameter must be a class annotated with @Entity or a collection/array of it. - obj in core.persistence.database.dao.AbstractDao.update(TEntity)
    e: [ksp] Type of the parameter must be a class annotated with @Entity or a collection/array of it. - obj in core.persistence.database.dao.AbstractDao.updateAsync(TEntity)
    c
    • 2
    • 3
  • z

    Zac Sweers

    09/09/2025, 8:28 AM
    is there a way to generate KMP sources into hierarchical parent source sets? For example, this pattern is quite common on iOS
    Copy code
    listOf(iosX64(), iosArm64(), iosSimulatorArm64()).forEach {
      it.binaries.framework { baseName = "shared" }
    }
    But the result is any KSP generated code is duplicated for each type to their own source set even if just
    iosMain
    once would suffice
    👀 2
    e
    • 2
    • 6
  • r

    ralf

    09/11/2025, 10:12 PM
    I'm testing the latest version 2.0.3 released some minutes ago and see this without any other changes:
    Copy code
    * What went wrong:
    Some problems were found with the configuration of task ':recipes:common:impl:kspDebugKotlinAndroid' (type 'KspAATask').
      - Gradle detected a problem with the following location: '/Users/ralf/Development/app-platform/recipes/common/impl/build/generated/compose/resourceGenerator/kotlin/androidDebugResourceAccessors'.
    
        Reason: Task ':recipes:common:impl:kspDebugKotlinAndroid' uses this output of task ':recipes:common:impl:generateResourceAccessorsForAndroidDebug' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.
    
        Possible solutions:
          1. Declare task ':recipes:common:impl:generateResourceAccessorsForAndroidDebug' as an input of ':recipes:common:impl:kspDebugKotlinAndroid'.
          2. Declare an explicit dependency on ':recipes:common:impl:generateResourceAccessorsForAndroidDebug' from ':recipes:common:impl:kspDebugKotlinAndroid' using Task#dependsOn.
          3. Declare an explicit dependency on ':recipes:common:impl:generateResourceAccessorsForAndroidDebug' from ':recipes:common:impl:kspDebugKotlinAndroid' using Task#mustRunAfter.
    
        For more information, please refer to <https://docs.gradle.org/9.0.0/userguide/validation_problems.html#implicit_dependency> in the Gradle documentation.
    Anyone else? This from the changelog makes me suspicious
    Migrate KSP off AGP's legacy Variant API #2250
    j
    h
    e
    • 4
    • 12
  • t

    Tolriq

    09/12/2025, 6:53 AM
    After updating to 2.0.3 I'm getting the following error with Wire, but I'm not sure if it's a KSP, Wire or me error.
    Copy code
    A problem was found with the configuration of task ':modules:wear:wear-models:kspDebugKotlin' (type 'KspAATask').
      - Gradle detected a problem with the following location: '/modules/wear/wear-models/build/generated/source/wire/debug'.
        
        Reason: Task ':modules:wear:wear-models:kspDebugKotlin' uses this output of task ':modules:wear:wear-models:generateDebugProtos' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.
        
        Possible solutions:
          1. Declare task ':modules:wear:wear-models:generateDebugProtos' as an input of ':modules:wear:wear-models:kspDebugKotlin'.
          2. Declare an explicit dependency on ':modules:wear:wear-models:generateDebugProtos' from ':modules:wear:wear-models:kspDebugKotlin' using Task#dependsOn.
          3. Declare an explicit dependency on ':modules:wear:wear-models:generateDebugProtos' from ':modules:wear:wear-models:kspDebugKotlin' using Task#mustRunAfter.
        
        For more information, please refer to <https://docs.gradle.org/9.0.0/userguide/validation_problems.html#implicit_dependency> in the Gradle documentation.
    h
    • 2
    • 2
  • m

    Maya

    09/12/2025, 6:12 PM
    Hi all - KSP version 2.0.3 was released yesterday and includes the following changes and bug fixes: • Removed usages of deprecated KGP ApiVersion - #2400 • Android integration for KSP has moved on to the new Variant API - #2250 • Runtime warning was added for projects that opt out of KSP2 - #2538 • AGP version against which KSP is compiled has been upgraded - #255 To view all released versions of KSP, visit https://github.com/google/ksp/releases. Thanks! The KSP Team
    👏 2
    h
    b
    • 3
    • 3
  • p

    Phil Kagebein

    09/17/2025, 4:46 PM
    I'm in the process of upgrading my kotlin version from
    2.1.20
    -> and
    2.2.10
    , along with ksp from
    2.1.20-1.0.32
    ->
    2.2.10-2.0.2
    and since the upgrade, I am seeing some code generation issues. In my multiplatform project, I have an annotation processor that generates some code based off the class it is attached to. In addition to this annotation processor, I have a custom gradle plugin that needs to use the output of the annotation processor to function properly. Before the version upgrades, I linked the annotation processor to the gradle plugin via:
    Copy code
    target.tasks.withType<KspTaskMetadata>().all {
                saveStateTask.dependsOn(this)
            }
    
            target.tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinCompile<*>>().all {
                if (name != "kspCommonMainKotlinMetadata") {
                    dependsOn("kspCommonMainKotlinMetadata")
                }
            }
    So that
    kspCommonMainKotlinMetadata
    will run first and all the necessary code will be generated. Then the
    saveStateTask
    (what the custom gradle plugin runs) is dependent on
    kspCommonMainKotlinMetadata
    as well. Since the upgrade, I have had to change those dependencies to this since the types have changed:
    Copy code
    target.tasks.withType<KspAATask>().all {
        if (name == "kspCommonMainKotlinMetadata") {
            saveStateTask.dependsOn(this)
        }
    }
    
    target.tasks.withType<KotlinCompilationTask<*>>().all {
        if (name != "kspCommonMainKotlinMetadata") {
            dependsOn("kspCommonMainKotlinMetadata")
        }
    }
    However, after this change, on subsequent builds of any client, the ksp annotation processor will not generate any code, as it does not resolve any symbols. So it seems like the ksp compilation tasks sometimes do not run prior to resolving the annotations. Does anyone have any ideas what I could look to improve on?
    r
    • 2
    • 1
  • j

    JP Sugarbroad

    09/26/2025, 11:57 PM
    Copy code
    > Task :redacted:kspKotlin FAILED
    e: [ksp] Unknown error processing element
    e: [ksp] io.micronaut.inject.processing.ProcessingException
    I don't suppose there's more detail than this? Maybe a stack trace?
    m
    • 2
    • 12
  • a

    atlantis210

    09/30/2025, 5:38 AM
    Hey, did any of you did succeed in generating code in a KMM commonTest module ? I tried to search on this channel, but nothing did the trick for me
    g
    • 2
    • 1
  • u

    ursus

    10/07/2025, 5:38 PM
    I'm a complete codegen noob, but can someone explain to me - if I have codegen that generates new types & I reference the generated types - how can that build at all after say a fresh git clone? Isn't that a chicken & egg problem?
    r
    j
    +2
    • 5
    • 20
  • m

    Maya

    10/08/2025, 8:03 PM
    Hi all, KSP version 2.0.4 has been released and includes the following changes and bug fixes: • Unable to build on AGP 8.11.1 using KSP 2.2.20-2.0.3 due to class cast exception #2614 • Resolver#getJvmCheckedException(KSPropertyAccessor) throws IllegalArgumentException #2548 • ClassCastException when building with 2.2.20-2.0.3 #2598 • Replace KaFirStopWorldCacheCleaner with no-op implementation #2626 • BuildConfig values are not available during annotation process after upgrading ksp from 2.2.10-2.0.2 -> 2.2.20-2.0.3 #2597 • Missing Gradle task wiring with 2.2.20-2.0.3 #2595 • 2.2.20-2.0.3 + protobufJavalite build errors #2596 To view all released versions of KSP, visit https://github.com/google/ksp/releases. Thanks! The KSP Team
    🎉 9
  • r

    Robert Jaros

    10/10/2025, 4:49 AM
    Hi, any chance for 2.3.0-Beta1 compatible release before the weekend?
    z
    h
    • 3
    • 3
  • e

    ebtokyo

    10/14/2025, 6:18 AM
    Hi, I wonder if this issue could get some attention, the only reason we didn't merge ksp 2.2.20.x is because it produce additional 3500 lines of warning in our build, because we can't update yet to KSP2 : https://github.com/google/ksp/issues/2635
  • z

    Zac Sweers

    10/22/2025, 2:33 AM
    getting a bunch of renovate updates for 2.3.0 but not seeing any release. I know I harped on this before but want to knock on this again 🙂. Slightly different in this case, but same end problem https://kotlinlang.slack.com/archives/C013BA8EQSE/p1689880945169069
    ➕ 5
    j
    j
    t
    • 4
    • 4
  • m

    Maya

    10/22/2025, 5:10 PM
    Hi all, KSP version 2.3.0 has been released and includes the following changes and bug fixes: • KSP1 has been deprecated #2657 • KSP is now independent of Kotlin Versions #2658 To view all released versions of KSP, visit https://github.com/google/ksp/releases. Thanks, The KSP Team
    K 4
    🎉 6
    t
    j
    • 3
    • 2
  • e

    eygraber

    10/22/2025, 5:58 PM
    I closed this issue with klib cross compilation, thinking it was just an issue with KSP1, but it is still an issue with KSP 2.3.0. The KGP API for determining the state of cross compilation is currently targeted for Kotlin 2.3.20, but as of Kotlin 2.2.20 cross compilation is enabled by default. Does it make sense to flip the check in KSP to enable the task unless
    kotlin.native.enableKlibsCrossCompilation == false
    ?
  • j

    jamireh

    10/24/2025, 8:55 PM
    👋 Could I get a review/direction on https://github.com/google/ksp/pull/2665? This is blocking us from upgrading to KSP 2.3.0
    t
    • 2
    • 2