Firebase在发布模式下没有找到与对象序列化的属性 [英] Firebase No properties to serialize found with object in release mode

查看:161
本文介绍了Firebase在发布模式下没有找到与对象序列化的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个将实时位置数据推送到Firebase的方法:

prerivate $ 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); (myUuid!= null&& datetime!= null&& locationToDB.getTitle()!= null&&!myUuid.isEmpty()&&!datetime.isEmpty() ){
databaseRef.child(myUuid +-Android+ sessionType + datetime).setValue(locationToDB);

当我以调试模式构建应用程序时,它工作得很好。但是,当我在Google Play的发布模式下构建它时,它会停止在此行:

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

更具体地说:当我这样做的时候,一切正常:

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

它看起来像是传递一个对象,因为值在签名的APK中是不可能的?



错误:
例外com.google.firebase.database.DatabaseException:没有在类上找到序列化的属性$ b $添加 -keepclassmembers类com.yourcompany.models。** {*;}添加添加 } 在proguard-rules.pro做了诀窍。



Proguard规则文档


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

解决方案

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

Proguard Rules Documentation

这篇关于Firebase在发布模式下没有找到与对象序列化的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆