[MissingType] Room + @Parcelize entity fails KSP resolution under AGP 9 built-in Kotlin (still fails on 2.3.10)
- Dominant language
- Kotlin
- Stars
- 3.5k
- Forks
- 415
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 53
Description
**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):
```groovy
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:
```kotlin
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.
Contributor guide
Research direction
Reproduce the failure with the shown Song.kt entity and run kspDebugKotlin under AGP 9 built-in Kotlin, then compare it with @Parcelize removed and with org.jetbrains.kotlin.android. Trace the [MissingType] reported by RoomKspProcessor and add regression coverage showing that the @Entity + @Parcelize class resolves successfully under built-in Kotlin.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, kotlin
- Domain
- build-system, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100