0
votes

I have used Parcelize property of Android Extension to get Parcelable data class in Kotlin . It greatly reduces boiler plate code . Initially it was in experimental mode but now its stable . I have followed tutorial from below link Parcelable Link where I have made changes in gradle to add

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'



androidExtensions {
    features = ["parcelize"]
}

Initially , it did not give any compiler error , but on running the app , it gives unresolved reference error for viewbinding did with layout from kotlin . The import are good , and it works fine if Parcelize property is not included .

import kotlinx.android.synthetic.main.activity.*

What could be the issue ? Does it only tells to use Parcelize property of android extension and leave other properties included from android-extension plugin ?

1

1 Answers

0
votes
  1. You dont need to make changes in gradle files like:

    androidExtensions {
    features = ["parcelize"]
    

just make sure your libraries are up to date.

  1. Make sure that you are using annotation and implementing Parcelable

@Parcelize class YourClass : Parcelable

and also import looks like this:

import kotlinx.android.parcel.Parcelize