android-没有在类上找到序列化的属性

时间:2018-04-14 22:18:00

标签: android database firebase-realtime-database

我在我的应用程序中使用实时数据库(firebase),当我尝试插入值时,我有

  

“没有在类上找到序列化的属性”

我尝试了在stackoverflow中找到的所有答案,更改了proguard规则,将所有内容公开,将getter和@keep放在课堂之前 这是我的计划规则

if (!numero)
    numero = 1;

这是我的用户类,错误来自于 “mDatabase.child(用户ID).setValue(用户);”

# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/apple/Softwares/adt-bundle-mac-x86_64-20140702/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
# Add this global rule
-keepattributes Signature

# This rule will properly ProGuard all the model classes in
# the package com.yourcompany.models. Modify to fit the structure
# of your app.

-keep class  com.android.pfe.other.**{ *; }

#
# For more details, see
#   http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
#   public *;
#}

这是我称之为

的地方
    public User() {
        // Default constructor required for calls to DataSnapshot.getValue(com.android.pfe.other.User.class)
    }
    @IgnoreExtraProperties
   @Keep
   public class User implements Serializable {
    public String username;
    public String email;
    public List contact;
    public List article;
    public DatabaseReference mDatabase;
    public User(String username, String email) {
        this.username = username;
        this.email = email;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public void addUser(String UserId, String name, String email) {
        mDatabase = FirebaseDatabase.getInstance().getReference("User");
        User user = new User(name, email);
        mDatabase.child(UserId).setValue(user);
    }}

0 个答案:

没有答案