Firebase No properties to serialize found with object in release mode

家住魔仙堡 提交于 2019-12-18 06:14:12

问题


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


回答1:


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

Proguard Rules Documentation



来源:https://stackoverflow.com/questions/44473498/firebase-no-properties-to-serialize-found-with-object-in-release-mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!