我写了一个将实时位置数据推送到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:没有在类上找到的序列化属性
解决方法
添加-keepclassmembers类com.yourcompany.models.** {*;在proguard-rules.pro中完成了这个伎俩.