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; } }
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.