Search code examples
c#xamarin.formsxamarin.android

NuGet packages Xamarin.Forms and Xamarin.Firebase.Messaging are not working together


I created a new Android project in Visual Studio for Mac and I installed the NuGet packages Xamarin.Forms and Xamarin.Firebase.Messaging. But I get the following error if I use the NuGet packages Xamarin.Forms and Xamarin.Firebase.Messaging in my Android project:

/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/32.0.476/tools/Xamarin.Android.D8.targets(5,5): Error: java.lang.RuntimeException: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: /Users/myname/.nuget/packages/xamarin.google.guava.listenablefuture/1.0.0.5/buildTransitive/net6.0-android31.0/…/…/jar/guava-listenablefuture.jar : com/google/common/util/concurrent/ListenableFuture.class

I don’t get the error when I only use Xamarin.Forms in my Android project or if I only use Xamarin.Firebase.Messaging in my Android project.

I use Visual Studio for Mac 2022 17.4 (build 2406).

How can I use the NuGet packages Xamarin.Forms and Xamarin.Firebase.Messaging together in my Android project?

enter image description here


Solution

  • I found the answer here: https://github.com/xamarin/AndroidX/issues/535

    It seems to work now. I installed Xamarin.Google.Guava Version="31.1.0.4" and then I installed Xamarin.Firebase.Messaging and finally Xamarin.Forms. In addition, it was necessary to add this line to my .csproj file:

    <XamarinGoogleGuavaOptOut>true</XamarinGoogleGuavaOptOut>