Describe the bug
When I call com.chrynan.chords.util.putChord(key, chord)
to put a chord in a Bundle()
, then later call bundle.getChord(key)
, the chords library throws a SerializationException ("Expected Json Decoder").
To Reproduce
Here's my code putting the chord in a Bundle:
MyFragment().apply {
arguments = Bundle().apply {
putChord(KEY_CHORD, chord)
}
}
And here's the get:
arguments?.getChord(KEY_CHORD)
Expected behavior
The chord should be retrieved.
Desktop (please complete the following information):
- OS: Android
- Browser N/A
- Version 11
Smartphone (please complete the following information):
- Device: Emulated Pixel 4 XL API 30
- OS: Android
- Browser N/A
- Version 11
Stacktrace
2021-12-27 00:37:40.111 5630-5630/com.gbros.tabslite E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.gbros.tabslite, PID: 5630
kotlinx.serialization.SerializationException: Expected Json Decoder for com.chrynan.parcelable.core.ParcelDecoder@4761331.
at com.chrynan.chords.model.serializer.ChordMarkerJsonSerializer.deserialize(ChordMarkerJsonSerializer.kt:36)
at com.chrynan.chords.model.serializer.ChordMarkerJsonSerializer.deserialize(ChordMarkerJsonSerializer.kt:16)
at kotlinx.serialization.encoding.Decoder$DefaultImpls.decodeSerializableValue(Decoding.kt:260)
at kotlinx.serialization.encoding.AbstractDecoder.decodeSerializableValue(AbstractDecoder.kt:16)
at kotlinx.serialization.encoding.AbstractDecoder.decodeSerializableValue(AbstractDecoder.kt:43)
at kotlinx.serialization.encoding.AbstractDecoder.decodeSerializableElement(AbstractDecoder.kt:70)
at kotlinx.serialization.encoding.CompositeDecoder$DefaultImpls.decodeSerializableElement$default(Decoding.kt:535)
at kotlinx.serialization.internal.ListLikeSerializer.readElement(CollectionSerializers.kt:80)
at kotlinx.serialization.internal.ListLikeSerializer.readAll(CollectionSerializers.kt:76)
at kotlinx.serialization.internal.AbstractCollectionSerializer.merge(CollectionSerializers.kt:31)
at kotlinx.serialization.internal.AbstractCollectionSerializer.deserialize(CollectionSerializers.kt:43)
at kotlinx.serialization.encoding.Decoder$DefaultImpls.decodeSerializableValue(Decoding.kt:260)
at kotlinx.serialization.encoding.AbstractDecoder.decodeSerializableValue(AbstractDecoder.kt:16)
at kotlinx.serialization.encoding.AbstractDecoder.decodeSerializableValue(AbstractDecoder.kt:43)
at kotlinx.serialization.encoding.AbstractDecoder.decodeSerializableElement(AbstractDecoder.kt:70)
at com.chrynan.chords.model.Chord$$serializer.deserialize(Chord.kt:25)
at com.chrynan.chords.model.Chord$$serializer.deserialize(Chord.kt:25)
at kotlinx.serialization.encoding.Decoder$DefaultImpls.decodeSerializableValue(Decoding.kt:260)
at kotlinx.serialization.encoding.AbstractDecoder.decodeSerializableValue(AbstractDecoder.kt:16)
at com.chrynan.parcelable.android.AndroidParcelableUtilsKt.decodeFromParcel(AndroidParcelableUtils.kt:63)
at com.chrynan.parcelable.android.AndroidParceler.createFromParcel(AndroidParceler.kt:23)
at com.chrynan.parcelable.android.AndroidParcelBundleUtilsKt.decodeFromBundle(AndroidParcelBundleUtils.kt:88)
at com.chrynan.chords.util.ParcelableUtilsKt.getChord(ParcelableUtils.kt:104)
at com.gbros.tabslite.ChordFragment$chord$2.invoke(ChordFragment.kt:34)
at com.gbros.tabslite.ChordFragment$chord$2.invoke(ChordFragment.kt:34)
at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
at com.gbros.tabslite.ChordFragment.getChord(ChordFragment.kt:34)
at com.gbros.tabslite.ChordFragment.onCreateView(ChordFragment.kt:38)
at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2995)
at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:523)
at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:261)
at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1840)
at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1758)
at androidx.fragment.app.FragmentManager.execSingleAction(FragmentManager.java:1670)
at androidx.fragment.app.BackStackRecord.commitNow(BackStackRecord.java:317)
at androidx.viewpager2.adapter.FragmentStateAdapter.placeFragmentInViewHolder(FragmentStateAdapter.java:341)
at androidx.viewpager2.adapter.FragmentStateAdapter.onViewAttachedToWindow(FragmentStateAdapter.java:276)
at androidx.viewpager2.adapter.FragmentStateAdapter.onViewAttachedToWindow(FragmentStateAdapter.java:67)
at androidx.recyclerview.widget.RecyclerView.dispatchChildAttached(RecyclerView.java:7867)
at androidx.recyclerview.widget.RecyclerView$5.addView(RecyclerView.java:893)
at androidx.recyclerview.widget.ChildHelper.addView(ChildHelper.java:107)
2021-12-27 00:37:40.117 5630-5630/com.gbros.tabslite E/AndroidRuntime: at androidx.recyclerview.widget.RecyclerView$LayoutManager.addViewInt(RecyclerView.java:8902)
at androidx.recyclerview.widget.RecyclerView$LayoutManager.addView(RecyclerView.java:8860)
at androidx.recyclerview.widget.RecyclerView$LayoutManager.addView(RecyclerView.java:8848)
at androidx.recyclerview.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1645)
at androidx.recyclerview.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1591)
at androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:668)
at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:4309)
at androidx.recyclerview.widget.RecyclerView.onMeasure(RecyclerView.java:3686)
at android.view.View.measure(View.java:25466)
at android.view.ViewGroup.measureChild(ViewGroup.java:6928)
at androidx.viewpager2.widget.ViewPager2.onMeasure(ViewPager2.java:498)
at android.view.View.measure(View.java:25466)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:735)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:481)
at android.view.View.measure(View.java:25466)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6957)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at android.view.View.measure(View.java:25466)
at com.google.android.material.bottomsheet.BottomSheetBehavior.onMeasureChild(BottomSheetBehavior.java:463)
at androidx.coordinatorlayout.widget.CoordinatorLayout.onMeasure(CoordinatorLayout.java:831)
at android.view.View.measure(View.java:25466)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6957)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at android.view.View.measure(View.java:25466)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6957)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at androidx.appcompat.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:145)
at android.view.View.measure(View.java:25466)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6957)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at android.view.View.measure(View.java:25466)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6957)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at android.view.View.measure(View.java:25466)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6957)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1552)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:842)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:721)
at android.view.View.measure(View.java:25466)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6957)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at com.android.internal.policy.DecorView.onMeasure(DecorView.java:747)
at android.view.View.measure(View.java:25466)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:3397)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:2228)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2486)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1952)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8171)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:972)
at android.view.Choreographer.doCallbacks(Choreographer.java:796)
at android.view.Choreographer.doFrame(Choreographer.java:731)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:957)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
2021-12-27 00:37:40.117 5630-5630/com.gbros.tabslite E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
2021-12-27 00:37:40.144 5630-5630/com.gbros.tabslite I/Process: Sending signal. PID: 5630 SIG: 9
Additional context
getChord()
uses com.chrynan.parcelable and calls (eventually) ChordMarkerJsonSerializer.deserialize, but calls it with a com.chrynan.parcelable.core.ParcelDecoder. That doesn't implement JsonDecoder
, so ChordMarkerJsonSerializer.kt
throws a SerializationException.
For reference, I'm working on TabsLite.