How do I replace annotation class Parcelize
from package kotlinx.android.parcel
with Parcelize which is not coming from the kotlin-android-extensions plugin?
This should be the new plugin: https://plugins.gradle.org/plugin/org.jetbrains.kotlin.plugin.parcelize
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'
}
When using kts you can write ->
// project build.gradle.kts
plugins {
..
kotlin("android") version "1.4.20" apply false
}
// app build.gradle.kts
plugins {
..
id("kotlin-parcelize")
}
--- OR Legacy Plugin Application ---
Step 1. Update to latest kotlin version - 1.4.20
and replace
apply plugin: 'kotlin-android-extensions'
with this ->
apply plugin: 'kotlin-parcelize'
Step 2. Remove this code from the android {}
androidExtensions {
experimental = true
}
Step 3. Finally, replace old import ->
import kotlinx.android.parcel.Parcelize
with new import
import kotlinx.parcelize.Parcelize
-
-
-
I'm new to android development and have no idea but
kotlinx
doesn't haveparcelize
submodule(?). – Hiro Feb 20 at 17:04
First you will need to add kotlin-parcelize
plugin to your module.
plugins {
..
id 'kotlin-parcelize'
}
Then change your old import statement from
import kotlinx.android.parcel.Parcelize
to
import kotlinx.parcelize.Parcelize
Edit (source): https://proandroiddev.com/migrating-the-deprecated-kotlin-android-extensions-compiler-plugin-to-viewbinding-d234c691dec7
-
1Thanks for the answer. Where exactly is this plugins {} code block supposed to go in? in the project level gradle file or app level gradle file? – abhiank Nov 20 '20 at 7:17
-
1found the answer. Its not available in the current kotlin stable version yet - medium.com/@drjacky/where-should-we-add-plugins-b85517b8a62f – abhiank Nov 20 '20 at 9:16
-
@G00fY Both 'kotlin-parcelize' and 'org.jetbrains.kotlin.plugin.parcelize' are working for me. – abhiank Nov 23 '20 at 19:05
-
what about this line : classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version" – Vikas Pandey Dec 28 '20 at 12:52