firebase / firebase/firebase-android-sdk
GenericTypeIndicator missing from firestore library but required
- Dominant language
- Java
- Stars
- 2.6k
- Forks
- 710
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 31
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)
```
Contributor guide
Assessment
This issue has not been assessed yet.