[Android] Firestore: Couldn't put object of type Plugin.Firebase.Android.Firestore.DocumentReferenceWrapper into HashMap
See original GitHub issueHi @TobiasBuchholz, I am currently testing your library on my Android app, and there’s actually an error when setting data to a document reference using : batch.SetData(shortUserReference, shortUserAccount);
StackTrace
System.ArgumentException: Couldn't put object of type Plugin.Firebase.Android.Firestore.DocumentReferenceWrapper into HashMap
at System.Collections.Generic.DictionaryExtension.Put (Java.Util.IMap this, System.Object key, System.Object value) [0x00273] in <becdb5103fb14132a70e7e52fa7d7747>:0
at System.Collections.Generic.DictionaryExtension.ToHashMap (System.Object this) [0x00050] in <becdb5103fb14132a70e7e52fa7d7747>:0
at Plugin.Firebase.Android.Firestore.WriteBatchWrapper.SetData (Plugin.Firebase.Firestore.IDocumentReference document, System.Object data, Plugin.Firebase.Firestore.SetOptions options) [0x00032] in <becdb5103fb14132a70e7e52fa7d7747>:0
Setup
Visual Studio Community 2022 for Mac (17.0.7) Xamarin.Android (12.3.3.3) Xamarin.Forms (5.0.0.2012) Plugin.Firebase V1.1.2
Here is an extract of the model I’m trying to store :
public partial class ShortUser
{
[FirestoreProperty(nameof(Username))]
public string Username { get; set; }
[FirestoreProperty(nameof(UserId))]
public IDocumentReference UserId { get; set; }
[FirestoreProperty(nameof(ProfilePicture))]
public Photo ProfilePicture { get; set; }
}
Context
I guess it’s the IDocumentReference field that is causing the issue. But I’ve seen something similar which you already solved in the past : #7 Could you please have a look ? Thanks in advance for your help 🙏
Issue Analytics
- State:
- Created a year ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Firestore: Couldn't put object of type System.Collections. ...
Issue: The firetore feature shows an error when when uploading a 'firestore-Map' ( a dictionary in the c# world) into the firestore database....
Read more >Android Firestore HashMap cannot be cast to Object
I try to get data from Firebase and store it in a ArrayList<Object> . To do so I created this method: private void...
Read more >Get started with Cloud Firestore - Firebase
This quickstart shows you how to set up Cloud Firestore, add data, then view the data you just added in the Firebase console....
Read more >Adding data | Firestore
There are several ways to write data to Firestore: Set the data of a document within a collection, explicitly specifying a document identifier....
Read more >Cloud Firestore
Firestore is a flexible, scalable NoSQL cloud database to store and sync data. It keeps your data in sync across client apps through...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hmm, after running your test project both button clicks seemed to work, see the screenshots:
I’ve created a test for it myself and also couldn’t reproduce this errror. If I’m looking at your stacktrace, I think the commit https://github.com/TobiasBuchholz/Plugin.Firebase/commit/984f79cbe927d3128e0a464d1b1c1daa69517789 has fixed this issue already and was released with the plugin version 1.1.0.
Maybe you have some older version cached or something like this? Otherwise I’ve no idea how this could be possible.
Referencing your package from the right source did fix the issue, closing ticket, thanks Tobias for your help.