java.lang.RuntimeException: Could not deserialize object. Class com.example.knowledgegain.User does not define a no-argument constructor. If you are using ProGuard, make sure these constructors are not stripped.
or any other way of getting data from Firestore in this situation?
public class WalletFragment extends Fragment {
public WalletFragment() {
// Required empty public constructor
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
FragmentWalletBinding binding;
FirebaseFirestore database;
User user;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
binding = FragmentWalletBinding.inflate(inflater,container,false);
database = FirebaseFirestore.getInstance();
try {
database.collection("User").document(FirebaseAuth.getInstance().getUid())
.get().addOnSuccessListener(new OnSuccessListener<DocumentSnapshot>() {
@Override
public void onSuccess(DocumentSnapshot documentSnapshot) {
try {
user = documentSnapshot.toObject(User.class);
binding.showCoinsId.setText(String.valueOf(user.getCoins()));
}catch (Exception e){
Log.e("TAG", "onSuccess: ", e );
}
}
});
}catch (Exception e){
Log.d("TAg", e.toString());
Toast.makeText(getContext(),e.toString(),Toast.LENGTH_LONG).show();
}
return binding.getRoot();
}
}