Xamarin Android, java class ListenableFuture is defined multiple times, with new Andriod App
Asked Answered
B

1

6

I created a brand spanking new Xamarin Android App in Visual Studio 2022.

I then referenced the v1.0.17.2 of the Xamarin.Stripe.Terminal.Android library as I need to perform some transactions on a card reader.

I compiled the solution without touching a line of code and I got the following issue

Type com.google.common.util.concurrent.ListenableFuture is defined multiple times: C:\Users\XYZ.nuget\packages\xamarin.google.guava.listenablefuture\1.0.0.2\buildTransitive\monoandroid50\guava-listenablefuture.jar:com/google/common/util/concurrent/ListenableFuture.class, obj\Debug\120\lp\54\jl\guava-28.1-android.jar:com/google/common/util/concurrent/ListenableFuture.class

You can see two jar references in the error message

1.0.0.2\buildTransitive\monoandroid50\guava-listenablefuture.jar

obj\Debug\120\lp\54\jl\guava-28.1-android.jar

If I take the full java command line built by Visual Studio, and I then remove the reference the jar

1.0.0.2\buildTransitive\monoandroid50\guava-listenablefuture.jar

then java compiles correctly from the command line, with a slew of warnings.


I'm just wondering if there is some way to exclude this JAR from the compile process in Visual Studio, so that the build can continue on correctly.

Any guidance would be much appreciated.

Bramwell answered 14/1, 2022 at 13:20 Comment(5)
Maybe this can help: #70907593Michi
@Bramwell did you find an answer for this?Laughingstock
@Laughingstock I need to revist this, I got a notification recently that the git repo has been updated and there may be a later nuget version there.Bramwell
Thanks, if it's a public repo I can you share it? otherwise I m waiting for your feedback :)Laughingstock
Hi @fandro, the 2.5.2 branch has been merged into master, but they have not released a new version of the nuget packages after the build. github.com/Square-Six/Xamarin.Stripe.Terminal.AndroidBramwell
P
0

I encountered what looks to the the exact same issue when upgrading my Avalonia project from 11.0.6 to 11.0.10. I found the solution here: https://github.com/xamarin/AndroidX/issues/535

The most relevant part being this:

<XamarinGoogleGuavaListenableFutureOptOut>true</XamarinGoogleGuavaListenableFutureOptOut>

that you can add to a PropertyGroup in your .csproj to exlude guava-listenablefuture.jar from the build.

In case that is not enough on its own the post also mentions explicitly referencing Guava and Guava.ListenableFuture packages to ensure the most recent version is being used and/or adding <XamarinGoogleGuavaOptOut>true</XamarinGoogleGuavaOptOut> to exclude guava.jar

Papagena answered 29/4, 2024 at 16:46 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.