SnapshotParser在发布版本和调试版本上的工作方式不同

时间:2018-12-03 13:37:12

标签: android firebase-realtime-database firebaseui android-proguard

我在发布模式下运行应用程序时遇到问题。 正确返回了我的Workshop对象的所有数据,但“地图用户”列出了。相同的代码在调试模式下运行没有任何问题。

  • 我使用useProguard false和minifyEnabled false禁用了Proguard。问题仍然存在。
  • 我在工场和用户模块中添加了@Keep注释。问题仍然存在。

我通过快照解析器获得了我的用户列表,如下所示:

FirebaseRecyclerOptions<Workshop> options =
        new FirebaseRecyclerOptions.Builder<Workshop>()
                .setQuery(query, new SnapshotParser<Workshop>() {
                    @NonNull
                    @Override
                    public Workshop parseSnapshot(@NonNull DataSnapshot snapshot) {
                        GenericTypeIndicator<Workshop> t = new GenericTypeIndicator<Workshop>() {
                        };
                        Workshop workshop = snapshot.getValue(t);
                        return workshop;
                    }
                })
                .build();

这是我的Workshop模块:

    @Keep
public class Workshop implements Serializable {

    private String date;
    private String time;
    private String description;
    private String name;
    private String address;
    private String city;
    Map<String, User> users = new HashMap<>();

    // empty constructor for firebase
    public Workshop() {
    }

    public Workshop(String date, String time, String description, String name, String address, String city,
                       Map<String, User> users) {
        this.date = date;
        this.time = time;
        this.description = description;
        this.name = name;
        this.address = address;
        this.city = city;
        this.users = users;
    }

    public Workshop(String date, String time, String description, String name, String address, String city) {
        this.date = date;
        this.time = time;
        this.description = description;
        this.name = name;
        this.address = address;
        this.city = city;
    }

0 个答案:

没有答案