chrynan / serialization-parcelable Goto Github PK
View Code? Open in Web Editor NEWAndroid Parcelable support for the Kotlinx Serialization library.
License: Apache License 2.0
Android Parcelable support for the Kotlinx Serialization library.
License: Apache License 2.0
Describe the bug
When I'm trying to transfer Serializable data through Bundle, I use methods putParcelable and getParcelable to parcelize it but the result data is broken.
To Reproduce
Params:
@Serializable
data class Params(val intro: Boolean)
val params = Params(true)
val bundle = Bundle()
bundle.putParcelable("key", params)
bundle.getParcelable("key")
Result behavior
Params(false)
Expected behavior
Params(true)
val params = Params(false)
val bundle = Bundle()
bundle.putParcelable("key", params)
bundle.getParcelable("key")
Result behavior
null
Expected behavior
Params(false)
Additional context
Serialization-parcelable - 0.5.1 (version 0.5.0 works fine)
Kotlin - 1.7.20
Kotlin-serialization - 1.4.1
Looking at the Maven repository index, the following artifacts weren't published for version 0.8.0:
The Gradle module metadata is missing the android*Elements-published
variants, so upgrading to 0.8.0 results in Gradle selecting the JVM variant for Android builds, which is definitely broken.
So there's no need to add one more repository to project
The init block in ByteArrayParcel
throws an NPE because data
is not set when setDataFromByteArray
runs.
I'm not sure if this is caused by a compiler change in Kotlin 1.7, because ordinarily you'd get a compiler diagnostic like "data is not initialized".
The easiest fix would be to move the init { }
block below where the data
property is initialized.
Stacktrace:
Cannot invoke "java.util.List.clear()" because "this.data" is null
java.lang.NullPointerException: Cannot invoke "java.util.List.clear()" because "this.data" is null
at com.chrynan.parcelable.core.ByteArrayParcel.setDataFromByteArray(ByteArrayParcel.kt:188)
at com.chrynan.parcelable.core.ByteArrayParcel.<init>(ByteArrayParcel.kt:17)
at com.chrynan.parcelable.core.ByteArrayParcel.<init>(ByteArrayParcel.kt:14)
at com.chrynan.parcelable.core.JvmParcelKt.Parcel(JvmParcel.kt:3)
Hi,
Why need be Min Android 23?
This can be downgraded to version 21?
Thanks.
Describe the bug
There is a bug in library that happens only on Pixel devices.
Fatal Exception: java.lang.RuntimeException: Parcel android.os.Parcel@52c801c: Unmarshalling unknown type code 6357038 at offset 8
at android.os.Parcel.readValue(Parcel.java:3305)
at android.os.Parcel.readArrayMapInternal(Parcel.java:3623)
at android.os.BaseBundle.initializeFromParcelLocked(BaseBundle.java:292)
at android.os.BaseBundle.unparcel(BaseBundle.java:236)
at android.os.Bundle.filterValues(Bundle.java:395)
at android.os.Bundle.filterValues(Bundle.java:405)
at android.content.Intent.removeUnsafeExtras(Intent.java:8859)
at android.app.ActivityThread.handleRequestAssistContextExtras(ActivityThread.java:3890)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2171)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7839)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
I can't reproduce it, but we have a lot of bugs in firebase crashlytics. With no specific case, any screen with your parcelable between intents/fragments inside intent is potential threat.
Smartphone (please complete the following information):
Additional context
It is happening with version 0.3.1, I have simultaneously upgraded to 0.4.1 and will give feedback whether it still happens.
Describe the bug
The Parcelable.decodeFromBundle()
functions impose an upper bound of <T : Any>
on the value type, which doesn't mirror the decodeFromByteArray
and decodeFromParcel
functions.
I'm optimistic that the : Any
bound could simply be removed, as it's the serializer's job to encode/decode null
and not-null marks.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.