question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Android] Firestore: Couldn't put object of type Plugin.Firebase.Android.Firestore.DocumentReferenceWrapper into HashMap

See original GitHub issue

Hi @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:closed
  • Created a year ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
TobiasBuchholzcommented, Aug 18, 2022

Hmm, after running your test project both button clicks seemed to work, see the screenshots:

Screenshot_20220818-153515 Screenshot_20220818-153524

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.

0reactions
Kapuschcommented, Aug 21, 2022

Referencing your package from the right source did fix the issue, closing ticket, thanks Tobias for your help.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found