You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I observed a problem when I updated from targetSdkVersion 27 to targetSdkVersion 29 in a project. GSON failes to serialize a Location object when using targetSdkVersion 29.
Location JSON string produced with targetSdkVersion 27
Only mElapsedRealtimeNanos get serialized when using 29. Location implements @Parcelable as far as I know. I am using the following code to handle de/serialization:
data class WayPoint(var location: Location = Location(LocationManager.GPS_PROVIDER)): Parcelable {
constructor(parcel: Parcel) : this(parcel.readParcelable(Location::class.java.classLoader) ?: Location(LocationManager.GPS_PROVIDER)) {
}
override fun writeToParcel(parcel: Parcel, flags: Int) {
parcel.writeParcelable(location, flags)
}
override fun describeContents(): Int {
return 0
}
companion object CREATOR : Parcelable.Creator<WayPoint> {
override fun createFromParcel(parcel: Parcel): WayPoint {
return WayPoint(parcel)
}
override fun newArray(size: Int): Array<WayPoint?> {
return arrayOfNulls(size)
}
}
}
The text was updated successfully, but these errors were encountered:
Thanks for the quick answer. I will copy over the values from the Location object to my own WayPoint class. That should result in a shorter JSON string as a side effect.
I observed a problem when I updated from
targetSdkVersion 27
totargetSdkVersion 29
in a project. GSON failes to serialize a Location object when usingtargetSdkVersion 29
.Location JSON string produced with targetSdkVersion 27
"location":{"mAltitude":0.0,"mBearing":0.0,"mBearingAccuracyDegrees":0.0,"mElapsedRealtimeNanos":33676559450037,"mHorizontalAccuracyMeters":20.0,"mLatitude":38.06770166666667,"mLongitude":-122.58285666666667,"mProvider":"gps","mSpeed":0.0,"mSpeedAccuracyMetersPerSecond":0.0,"mTime":1573423211000,"mVerticalAccuracyMeters":0.0}
Location JSON string produced with targetSdkVersion 29
"location":{"mElapsedRealtimeNanos":33918570517227}
Only
mElapsedRealtimeNanos
get serialized when using29
. Location implements@Parcelable
as far as I know. I am using the following code to handle de/serialization:The text was updated successfully, but these errors were encountered: