Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase No properties to serialize found with object in release mode

I've written a method for pushing real-time location data to Firebase:

private void writeNewMarker(int sessionType, String myUuid, String datetime, Location location) {
    locationToDB = new LocationFromAndroid();
    JSONObject jsonObjectCoords = new Coords(location.getLatitude() + "", location.getLongitude() + "", location.getAltitude() + "");
    locationToDB.setFinish("false");
    locationToDB.setLost("false");
    locationToDB.setCoords(jsonObjectCoords);
    locationToDB.setDistanceToGo("0");
    locationToDB.setHeading(location.getBearing() + "");
    locationToDB.setNauwkeurigheid(location.getAccuracy() + "");
    locationToDB.setSpeed(location.getSpeed() * 3.6 + "");
    locationToDB.setSpeed2(location.getSpeed() + "");
    locationToDB.setTimestamp(location.getTime() + "");
    locationToDB.setWp_user(myUuid);
    locationToDB.setSessionType(sessionType);
    locationToDB.setTitle(title);
    if(myUuid != null && datetime != null && locationToDB.getTitle() != null && !myUuid.isEmpty() && !datetime.isEmpty()) {
        databaseRef.child(myUuid + "-Android" + sessionType + datetime).setValue(locationToDB);

When I'm building the app in debug mode, it works perfectly fine. But when I'm building it in Release mode for Google Play, it stops working at this line:

databaseRef.child(myUuid + "-Android" + sessionType + datetime).setValue(locationToDB);

To be more specific: When I'm doing this, everything is OK:

databaseRef.child(myUuid + "-Android" + sessionType + datetime).setValue("Test");

It does look like passing an object as value isn't possible within a signed APK?

Error: Exception com.google.firebase.database.DatabaseException: No properties to serialize found on class

like image 888
Bart Ros Avatar asked Jun 10 '17 12:06

Bart Ros


1 Answers

Adding -keepclassmembers class com.yourcompany.models.** { *; } in proguard-rules.pro did the trick.

Proguard Rules Documentation

like image 111
Bart Ros Avatar answered Nov 02 '22 23:11

Bart Ros