I am trying to retrieve my user details from the /User/ tree i have in Firebase. I have the following User object :
public class User {
private String
The User has no arguments error means that even though you do need an empty constructor:
public User(){ }
You will also need another constructor with the variables that are children in your object in Firebase inside of the constructor. For instance:
public User(
String name,
String email,
FirebaseUser firebaseUser,
String lastOnline,
LatLng latLng,
ArrayList locations
){
this.name = name;
this.email = email;
this.firebaseUser = firebaseUser;
this.lastOnline = lastOnline;
this.latLong = latLong;
this.locations = locations;
}
Also be careful with classes inside of the constructors such as SwapLocation, if it is not automatically parsed, you need to modify it the same way.
In the other hand, in Kotlin you should not instantiate with empty values, instead you should instantiate with null and add @IgnoreExtraProperties and @Keep on top to load attributes only if they exist in the data. For instance:
@Keep
@IgnoreExtraProperties
open class User(
var name : String? = null,
var email : String? = null,
var firebaseUser : FirebaseUser? = null,
var lastOnline : String? = null,
var latLng : LatLng? = null,
var locations : ArrayList? = null
)
Hope it helps!