If using Plugins DSL you can use the plugin ID in submodules. Make sure that the latest Kotlin Android plugin is available from the project's classpath.
// project build.gradle
plugins {
..
id "org.jetbrains.kotlin.android" version "1.4.20" apply false
}
// app build.gradle
plugins {
..
id 'kotlin-parcelize'
}
dependencies {
// .... project level dependencies
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.20-RC"
}
build.gradle (app level)
plugins {
...
id 'kotlin-parcelize'
}
and the data class
import android.os.Parcelable
import kotlinx.parcelize.Parcelize
@Parcelize
class User(
val firstName: String,
val lastName: String,
val age: Int
): Parcelable
kotlin-android-extensions is deprecated so replace it from kotlin-parcelize
If there is @Parcelize annotation used for model classes so you have to replace its import from kotlinx.android.parcel.Parcelize to import kotlinx.parcelize.Parcelize