简体   繁体   中英

Error when changing the Firebase database in Android

I have imported a code for the Firebase Chat from a friend, including the google-services.json file, in which the certificates and the link to his database is stored.

The code worked perfectly, but then I wanted to connect the chat to my database so I have deleted his json file and inserted mine, with my database info.

Now the chat opens, one can log in, but it crashes with this error:

 com.google.firebase.database.DatabaseException: Can't convert object
 of type java.lang.String to type

So I can track this to a class file that has this inside:

 public class ChatMessage { private String messageText; private String messageUser; private long messageTime; public ChatMessage(String messageText, String messageUser) { this.messageText = messageText; this.messageUser = messageUser; messageTime = new Date().getTime(); } public ChatMessage() { } public String getMessageText() { return messageText; } public void setMessageText(String messageText) { this.messageText = messageText; } public String getMessageUser() { return messageUser; } public void setMessageUser(String messageUser) { this.messageUser = messageUser; } public long getMessageTime() { return messageTime; } public void setMessageTime(long messageTime) { this.messageTime = messageTime; } } 

The question are...

  1. why do I get that error?
  2. Is there something else I need to fix in my Firebase database? Is it the code? But that wouldn't make sense, since it works with his database.
  3. How can one make this database transition and how can I make it work with my database?

try to add default constructor.
public ChatMessage() {

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM