I am following https://developer.android.com/jetpack/compose/state#parcelize to make a Parcelable data class with Kotlin in Jetpack Compose, however the @Parcelize
annotation is not available to be imported.
I can add the block below to my code, and can import Parcelable fine, but not Parcelize:
@Parcelize
data class City(val name: String, val country: String) : Parcelable
I read https://stackoverflow.com/a/64948848/11162441 and added id 'org.jetbrains.kotlin.plugin.parcelize' version '1.7.22' apply false
to my project-level Gradle build and synced, however I am still not able to import the annotation. I am using Android Kotlin version 1.7.10.
If the Parcelize annotation is out-dated, I want to use the latest annotation.
In your module-level build.gradle
file you should have the following:
plugins {
id 'kotlin-parcelize'
}
I never imported parcelize into the project-level gradle file, try this.