Class java.util.Map has generic type parameters, please use GenericTypeIndicator instead
The error points out correctly where you are going wrong
Map<String, String> map = dataSnapshot.getValue(Map.class);
Map class uses parameter to define the types of Key and Object where as you don't give them and simply use Map.class
which fails.
Try the below code - since Key are always string and we can have any type of Object for them
Map<String, Object> map = (Map<String, Object>) dataSnapshot.getValue();
To introduce the GenericTypeIndicator
, you can change this line:
Map<String, String> map = dataSnapshot.getValue(Map.class);
in to this:
GenericTypeIndicator<Map<String, String>> genericTypeIndicator = new GenericTypeIndicator<Map<String, String>>() {};
Map<String, String> map = dataSnapshot.getValue(genericTypeIndicator );
This should work well in your case. Please give it a try and let me know.
I had the same problem and solved it by handling the Object instead trying to have Firebase cast it.
Map <String, String> map = (Map)dataSnapshot.getValue();
did it for me.