i use Firebase as backend for my app. But i cant serialize PolylineOptions from Firebase back to a PolylineOptions type. If i try to convert it back with dataSnapshot.getValue(PolylineOptions.class); , i have the following error message:
com.firebase.client.FirebaseException: Failed to bounce to type
....
Caused by: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException:
Unrecognized field "width" (class com.google.android.gms.maps.model.PolylineOptions), not marked as ignorable (one known property: "points"])
....
at com.fasterxml.jackson.databind.DeserializationContext.reportUnknownProperty(DeserializationContext.java:555)
How can I fix that problem?
Here is the code which demonstrates the issue:
import android.location.Location;
import android.os.Bundle;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import com.firebase.client.Query;
import com.google.android.gms.maps.model.PolylineOptions;
import com.google.android.gms.maps.model.LatLng;
import com.firebase.client.DataSnapshot;
import com.firebase.client.Firebase;
import com.firebase.client.FirebaseError;
import com.firebase.client.ValueEventListener;
public class MainActivity extends AppCompatActivity{
PolylineOptions mPolylineOptions;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mPolylineOptions = new PolylineOptions();
Location targetLocation = new Location("name");
targetLocation.setLatitude(1.0d);
targetLocation.setLongitude(2.0d);
mPolylineOptions.add(new LatLng(targetLocation.getLatitude(), targetLocation.getLongitude()));
mPolylineOptions.color(ContextCompat.getColor(this, R.color.colorPrimary));
Firebase.setAndroidContext(this);
Firebase ref = new Firebase("https://xxxxxxx");
Firebase testRef = ref.child("test");
final Query queryRef = testRef.orderByKey();
queryRef.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
Log.d("Test", "data change");
PolylineOptions activity1 = dataSnapshot.getValue(PolylineOptions.class);
}
@Override
public void onCancelled(FirebaseError firebaseError) {
System.out.println("The read failed: " + firebaseError.getMessage());
}
});
testRef.setValue(mPolylineOptions);
}
}
Here is the JSON from Firebase:
Here is the JSON from Firebase:
{
"test" : {
"clickable" : false,
"color" : -12627531,
"geodesic" : false,
"points" : [ {
"latitude" : 50.68468468468468,
"longitude" : 8.190167190445726
} ],
"visible" : true,
"width" : 10.0,
"zindex" : 0.0
}
}