Firebase 在发布模式下找不到要序列化的对象的属性
Firebase No properties to serialize found with object in release mode
我写了一个将实时位置数据推送到 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);
当我在调试模式下构建应用程序时,它运行得非常好。但是当我在发布模式下为 Google Play 构建它时,它在这一行停止工作:
databaseRef.child(myUuid + "-Android" + sessionType + datetime).setValue(locationToDB);
更具体地说:当我这样做时,一切正常:
databaseRef.child(myUuid + "-Android" + sessionType + datetime).setValue("Test");
似乎在已签名的 APK 中传递对象是不可能的?
错误:
异常 com.google.firebase.database.DatabaseException:在 class
上找不到要序列化的属性
在 proguard-rules.pro 中添加 -keepclassmembers class com.yourcompany.models.** { *; }
就成功了。
我写了一个将实时位置数据推送到 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);
当我在调试模式下构建应用程序时,它运行得非常好。但是当我在发布模式下为 Google Play 构建它时,它在这一行停止工作:
databaseRef.child(myUuid + "-Android" + sessionType + datetime).setValue(locationToDB);
更具体地说:当我这样做时,一切正常:
databaseRef.child(myUuid + "-Android" + sessionType + datetime).setValue("Test");
似乎在已签名的 APK 中传递对象是不可能的?
错误: 异常 com.google.firebase.database.DatabaseException:在 class
上找不到要序列化的属性在 proguard-rules.pro 中添加 -keepclassmembers class com.yourcompany.models.** { *; }
就成功了。