Kotlin version: 2.2.21
KSP version: tested 2.3.1 and 2.3.10 (same failure on both)
AGP version: 9.3.0, built-in Kotlin enabled (android.builtInKotlin default, android.newDsl default — i.e. not opted out)
Gradle version: 9.5.0
Room version: 2.8.4 (androidx.room:room-compiler via ksp)
Describe the bug
Under AGP 9's built-in Kotlin, KSP's type resolution fails for a Room
@Entity class that also carries kotlin-parcelize's @Parcelize. Room's
KSP processor aborts with [MissingType], and the same class compiles and
processes fine as soon as @Parcelize/Parcelable is removed — with
everything else (KSP version, AGP version, built-in Kotlin enabled) held
identical.
This is not the R-class resolution bug fixed in 2.3.10 (#2857) — I upgraded
from 2.3.1 to 2.3.10 specifically expecting that fix to cover this, and hit
the identical failure on both.
Repro
plugins block (module-level):
plugins {
id 'com.android.application'
id 'com.google.devtools.ksp'
id 'androidx.room'
id 'kotlin-parcelize'
// no org.jetbrains.kotlin.android — using AGP's built-in Kotlin
}
Entity:
import android.os.Parcelable
import androidx.room.Entity
import androidx.room.PrimaryKey
import kotlinx.parcelize.Parcelize
@Parcelize
@Entity(tableName = "songs")
data class Song(
@PrimaryKey val id: String,
val title: String,
// ...more fields, all Room-supported primitive/String/nullable types
) : Parcelable
Running kspDebugKotlin fails:
e: [ksp] .../Song.kt:16: [MissingType]: Element 'com.example.Song' references a type that is not present
e: [ksp] androidx.room.RoomKspProcessor was unable to process 'com.example.MusicDatabase' because not all of its dependencies could be resolved. Check for compilation errors or a circular dependency with generated code.
> Task :app:kspDebugKotlin FAILED
> A failure occurred while executing com.google.devtools.ksp.gradle.KspAAWorkerAction
> KSP failed with exit code: PROCESSING_ERROR
Removing @Parcelize/: Parcelable from Song (nothing else changed —
same KSP version, same AGP version, built-in Kotlin still enabled) makes
kspDebugKotlin succeed immediately.
With org.jetbrains.kotlin.android applied instead of built-in Kotlin
(i.e. android.builtInKotlin=false, android.newDsl=false), the same
@Parcelize + @Entity class processes without error on the same KSP
version. So this reproduces only with built-in Kotlin enabled.
Expected behavior
KSP should be able to resolve a class annotated with both @Entity and
@Parcelize under built-in Kotlin, the same way it does under the classic
org.jetbrains.kotlin.android plugin.
Additional context
This is currently the only thing blocking a project of mine from dropping
the android.builtInKotlin/android.newDsl opt-out flags (AGP 10 removes
the ability to opt out entirely, so this needs to resolve before that
upgrade is possible). Happy to provide a minimal standalone reproduction
project if useful.
Kotlin version: 2.2.21
KSP version: tested 2.3.1 and 2.3.10 (same failure on both)
AGP version: 9.3.0, built-in Kotlin enabled (
android.builtInKotlindefault,android.newDsldefault — i.e. not opted out)Gradle version: 9.5.0
Room version: 2.8.4 (
androidx.room:room-compilerviaksp)Describe the bug
Under AGP 9's built-in Kotlin, KSP's type resolution fails for a Room
@Entityclass that also carrieskotlin-parcelize's@Parcelize. Room'sKSP processor aborts with
[MissingType], and the same class compiles andprocesses fine as soon as
@Parcelize/Parcelableis removed — witheverything else (KSP version, AGP version, built-in Kotlin enabled) held
identical.
This is not the R-class resolution bug fixed in 2.3.10 (#2857) — I upgraded
from 2.3.1 to 2.3.10 specifically expecting that fix to cover this, and hit
the identical failure on both.
Repro
pluginsblock (module-level):plugins { id 'com.android.application' id 'com.google.devtools.ksp' id 'androidx.room' id 'kotlin-parcelize' // no org.jetbrains.kotlin.android — using AGP's built-in Kotlin }Entity:
Running
kspDebugKotlinfails:Removing
@Parcelize/: ParcelablefromSong(nothing else changed —same KSP version, same AGP version, built-in Kotlin still enabled) makes
kspDebugKotlinsucceed immediately.With
org.jetbrains.kotlin.androidapplied instead of built-in Kotlin(i.e.
android.builtInKotlin=false,android.newDsl=false), the same@Parcelize+@Entityclass processes without error on the same KSPversion. So this reproduces only with built-in Kotlin enabled.
Expected behavior
KSP should be able to resolve a class annotated with both
@Entityand@Parcelizeunder built-in Kotlin, the same way it does under the classicorg.jetbrains.kotlin.androidplugin.Additional context
This is currently the only thing blocking a project of mine from dropping
the
android.builtInKotlin/android.newDslopt-out flags (AGP 10 removesthe ability to opt out entirely, so this needs to resolve before that
upgrade is possible). Happy to provide a minimal standalone reproduction
project if useful.