-
Notifications
You must be signed in to change notification settings - Fork 626
Description
[REQUIRED] Step 2: Describe your environment
- Android Studio version: 3.2.1
- Firebase Component: firestore
- Component version: 17.1.5
[REQUIRED] Step 3: Describe the problem
Steps to reproduce:
What Happened:
When you try to retrieve a object and turn it to a object with a generic with type parameters EX( a Map/HashMap) you get the error Could not deserialize object. Class java.util.HashMap has generic type parameters, please use GenericTypeIndicator instead
What would normally happen is using GenericTypeIndicator to define the types but that class isn't included with the firebase-firestore library for android and is only included in the firebase-database (com.firebase.client.GenericTypeIndicator
) android library.
To Reproduce:
Create a collection and a document with values ex:
{
"dude":"wow",
"whatever":32,
}
Retrieve item and convert to object with a with a generic map documentSnapshot.toObject(typeParameterClass)
Ex.: documentSnapshot.toObject(HashMap.class)
Relevant Code:
java.lang.RuntimeException: Could not deserialize object. Class java.util.HashMap has generic type parameters, please use GenericTypeIndicator instead
at com.google.firebase.firestore.util.CustomClassMapper.deserializeError(com.google.firebase:firebase-firestore@@17.1.5:524)
at com.google.firebase.firestore.util.CustomClassMapper.deserializeToClass(com.google.firebase:firebase-firestore@@17.1.5:232)
at com.google.firebase.firestore.util.CustomClassMapper.convertToCustomClass(com.google.firebase:firebase-firestore@@17.1.5:97)
at com.google.firebase.firestore.DocumentSnapshot.toObject(com.google.firebase:firebase-firestore@@17.1.5:203)
at com.google.firebase.firestore.DocumentSnapshot.toObject(com.google.firebase:firebase-firestore@@17.1.5:183)
at // My package
at // My package
at com.google.firebase.firestore.DocumentReference.lambda$addSnapshotListenerInternal$2(com.google.firebase:firebase-firestore@@17.1.5:541)
at com.google.firebase.firestore.DocumentReference$$Lambda$3.onEvent(Unknown Source:6)
at com.google.firebase.firestore.util.ExecutorEventListener.lambda$onEvent$0(com.google.firebase:firebase-firestore@@17.1.5:42)
at com.google.firebase.firestore.util.ExecutorEventListener$$Lambda$1.run(Unknown Source:6)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)