Google is recommending users to migrate from kotlin-android-extensions
to kotlin-parcelize
.
However, Gradle sync fails with the following error:
Plugin [id: 'kotlin-parcelize'] was not found in any of the following sources:
- Gradle Core Plugins (not a core plugin, please see https://docs.gradle.org/6.1.1/userguide/standard_plugins.html for available core plugins)
- Plugin Repositories (plugin dependency must include a version number for this source)
Where is the plugin located?
Just add the @Parcelize annotation to a class implementing the Parcelable interface and the Parcelable implementation will be generated automatically. This is the same example as in the previous article, in just 2 lines of code. The class can be a data class but it's optional.
kotlin-parcelize
ships with Kotlin Plugin 1.4.20
(Release Announcement: Deprecation of Kotlin Android Extensions)
You need to upgrade your Kotlin versions and run Gradle sync again.
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.20"
}
1, update your AndroidStudio kotlin version
From menu, select Tools -> Kotlin -> Configure Kotlin Plugin Updates
-> choose a kotlin version -> install -> and restart AS
2, update your dependencies classpath with the new kotlin version then sync project (like Brown Smith answer)
3
builld.gradle (:app)
plugins {
...
id 'kotlin-parcelize'
}
MyObject.kt
import kotlinx.parcelize.Parcelize
@Parcelize
class MyObject(val name: String, val age: Int) : Parcelable {
}
This is the latest september 2021
implementation :
If you're using 'org.jetbrains.kotlin.android' version '1.5.20'
or above , and you fail to find the parcelize tag , you can add it using the plugins DSL in the settings.gradle
:
plugins {
id "org.jetbrains.kotlin.plugin.parcelize" version "1.6.0-M1"
}
and then call it in your app build.gradle
like this :
plugins {
id 'org.jetbrains.kotlin.plugin.parcelize'
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With