问题
I am trying to add information to my firebase project using Xamarin android app but all of a sudden I got this message:
Error Message
Java.Lang.NoClassDefFoundError
Message=Failed resolution of: Lcom/google/common/base/Preconditions;
My GetDatabase method:
Imgur Link
NuGet Packages Installed:
- Xamarin.Android.Support.Core.Utils (ver 28.0.0.3)
- Xamarin.Android.Support.CustomTabs (ver 28.0.0.3)
- Xamarin.Android.Support.Design (ver 28.0.0.3)
- Xamarin.Android.Support.Media.Compat (ver 28.0.0.3)
- Xamarin.AndroidX.MultiDex (ver 2.0.1.4)
- Xamarin.Essentials (ver 1.5.3.2)
- Xamarin.Firebase.Auth (ver 71.1605.4)
- Xamarin.Firebase.Firestore (ver 71.1705.4)
- Xamarin.Google.Guava (ver 28.2.0)
- Xamarin.GooglePlayServices.Auth (ver 71.1600.4)
- XamarinLibrary.Xamarin.Android.Support.Multidex (ver 1.0.3)
Debug Log
https://paste.ubuntu.com/p/TDNGwSTDTG/
I tried to paste it here as text but it didn't like it :( ^^
- I have tried to rebuild the project on multiple occasions after each change
- As I saw in this site in a similar question I tried to downgrade Guava to 27.1.0.0 as well as 27.1.0.4
- Double checked the connection to google. I can confidently say so since I have implemented a firebase auth Google sign in option and it works as intented.
I am quite new to Xamarin and Firebase so please don't stone me xD
回答1:
There is a well known conflict beetween Guava, Xamarin.Firebase and AndroidX.
In my case I implemented AndroidX at the end as a new update, so I already had all the logistic configured with Firebase so the fastest, easiest and (for me) the best solution was to stop using AndroidX and start uninstalling all AndroidX package. (Let me tell you, it was a lot.)
It wasn't easy because even some of the last updates from Guava or Xamarin.Firebase if I recall correctly, depends on AndroidX so I recommend to check that before you update your Nuget packages.
So, long story short, my solution was to stop using AndroidX Nuget package.
At least until this issue got fix.
来源:https://stackoverflow.com/questions/64020091/google-firestore-error-getting-database-instance