I'm currently trying out the experimental (which might be why it's not working...) @Parcelize
annotation to generate Parcelable
code. Most types seem to be working fine, but I'm having issues with Serializable
s throwing a NoSuchMethodError
:
10-05 13:55:18.549 20808-20808/com.app E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.app, PID: 20808
java.lang.NoSuchMethodError: No virtual method writeSerializable(Ljava/util/Date;)V in class Landroid/os/Parcel;
or its super classes (declaration of 'android.os.Parcel' appears in /system/framework/framework.jar)
at com.app.models.Job.writeToParcel(Job.kt)
at android.os.Parcel.writeParcelable(Parcel.java:1496)
at android.os.Parcel.writeValue(Parcel.java:1402)
at android.os.Parcel.writeArrayMapInternal(Parcel.java:724)
at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1408)
at android.os.Bundle.writeToParcel(Bundle.java:1157)
at android.os.Parcel.writeBundle(Parcel.java:764)
at android.content.Intent.writeToParcel(Intent.java:8687)
at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:3082)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1518)
at android.app.Activity.startActivityForResult(Activity.java:4225)
at android.support.v4.app.BaseFragmentActivityApi16.startActivityForResult(BaseFragmentActivityApi16.java:54)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:65)
at android.app.Activity.startActivityForResult(Activity.java:4183)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:711)
at android.app.Activity.startActivity(Activity.java:4522)
at android.app.Activity.startActivity(Activity.java:4490)
I know I could fix this by changing the Date objects to Strings, but would rather not. Has anyone else run into this issue that could provide a viable workaround other than using Strings?
If needed, here's the implementation for reference:
@Parcelize
data class Job(val id: String,
val description: String,
val state: String,
val job_type: String?,
val close_on: Date?,
val posted_on: Date?) : Parcelable
Didn't find anything on SO, so rather than deleting I'll leave it here for reference incase anyone else runs into it. It looks like this has been logged as a bug that affects 1.1.4 and 1.1.50. (I was using 1.1.4).
Looks like it's been fixed for versions 1.1.6 and above.
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