Com.google.firebase.database.databaseexception: ожидание карты при десериализации, но получил класс java.lang.longAndroid

Форум для тех, кто программирует под Android
Ответить
Anonymous
 Com.google.firebase.database.databaseexception: ожидание карты при десериализации, но получил класс java.lang.long

Сообщение Anonymous »

IAM Ошибка столкновения: [ожидала карту при десериализации, но получил класс java.lang.long] в течение долгого времени .. Я пытался решить, но не работать < /p>
это mainActivity.java < /p>
< /p>
.public class MainActivity extends AppCompatActivity{

Button add_Dialoge;
FloatingActionButton add;
EditText title_Dialoge , note_Dialoge;
ListView listViewNote;
String title , note , mId;

FirebaseDatabase mDataBase = FirebaseDatabase.getInstance();
DatabaseReference mRef = mDataBase.getReference("Notes");

ArrayList mNoteList = null;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

add = findViewById(R.id.BTN_Add);
add.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showAlertDialogeAddNote(); }
});

listViewNote = findViewById(R.id.LV_ListViewNote);

mNoteList = new ArrayList();

}

@Override
protected void onStart() {
super.onStart();

mRef.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot data) {
// That Run When I Want To Get Data From FireBase

for (DataSnapshot snapshot : data.getChildren()){
Note note = snapshot.getValue(Note.class);
mNoteList.add(note);
}
noteAdapter adapter = new noteAdapter(MainActivity.this , mNoteList);
listViewNote.setAdapter(adapter);
}

@Override
public void onCancelled(@NonNull DatabaseError error) {
// That Run When Have Error
Log.e("The Read Failed Is .:. " ,error.getMessage());
}

});

}

void showAlertDialogeAddNote() {
AlertDialog.Builder alertBuilder = new AlertDialog.Builder(MainActivity.this);
View view = LayoutInflater.from(MainActivity.this).inflate(R.layout.layout_add_note , null);

title_Dialoge = view.findViewById(R.id.ET_Title_DialogAdd);
note_Dialoge = view.findViewById(R.id.ET_Note_DialogAdd);

add_Dialoge = view.findViewById(R.id.BTN_Add_DialogAdd);
add_Dialoge.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

title = title_Dialoge.getText().toString();
note = note_Dialoge.getText().toString();

if (title.isEmpty() && note.isEmpty()) {
Toast.makeText(MainActivity.this, "!! ERROR .. The Title Or Note Or Both Are Empty !!", Toast.LENGTH_LONG).show();
} else {
mId = mRef.push().getKey();
Note myNote = new Note(mId, title , note , ServerValue.TIMESTAMP);
mRef.child(mId).setValue(myNote);
}
}
});

alertBuilder.setView(view);
AlertDialog alertDialog = alertBuilder.create();
alertDialog.show();
}

}
< /code>
и мой класс примечаний: < /p>
public class Note {

public String id;
public String title , note;
public Map time;

public Note() {
}

Note(String id, String title, String note, Map time) {
this.id = id;
this.title = title;
this.note = note;
this.time = time;
}
< /code>
И моя ошибка.Process: com.example.notewithfirebase, PID: 4831
com.google.firebase.database.DatabaseException: Expected a Map while deserializing, but got a class java.lang.Long
at com.google.firebase.database.core.utilities.encoding.CustomClassMapper.expectMap(com.google.firebase:firebase-database@@19.2.1:344)
at com.google.firebase.database.core.utilities.encoding.CustomClassMapper.deserializeToParameterizedType(com.google.firebase:firebase-database@@19.2.1:261)
at com.google.firebase.database.core.utilities.encoding.CustomClassMapper.deserializeToType(com.google.firebase:firebase-database@@19.2.1:176)
at com.google.firebase.database.core.utilities.encoding.CustomClassMapper.access$100(com.google.firebase:firebase-database@@19.2.1:47)
at com.google.firebase.database.core.utilities.encoding.CustomClassMapper$BeanMapper.deserialize(com.google.firebase:firebase-database@@19.2.1:592)
at com.google.firebase.database.core.utilities.encoding.CustomClassMapper$BeanMapper.deserialize(com.google.firebase:firebase-database@@19.2.1:562)
at com.google.firebase.database.core.utilities.encoding.CustomClassMapper.convertBean(com.google.firebase:firebase-database@@19.2.1:432)
at com.google.firebase.database.core.utilities.encoding.CustomClassMapper.deserializeToClass(com.google.firebase:firebase-database@@19.2.1:231)
at com.google.firebase.database.core.utilities.encoding.CustomClassMapper.convertToCustomClass(com.google.firebase:firebase-database@@19.2.1:79)
at com.google.firebase.database.DataSnapshot.getValue(com.google.firebase:firebase-database@@19.2.1:203)
at com.example.notewithfirebase.MainActivity$2.onDataChange(MainActivity.java:67)
at com.google.firebase.database.core.ValueEventRegistration.fireEvent(com.google.firebase:firebase-database@@19.2.1:75)
at com.google.firebase.database.core.view.DataEvent.fire(com.google.firebase:firebase-database@@19.2.1:63)
at com.google.firebase.database.core.view.EventRaiser$1.run(com.google.firebase:firebase-database@@19.2.1:55)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)


Подробнее здесь: https://stackoverflow.com/questions/600 ... deserializ
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Android»