question

LeonardHarris-3315 avatar image
0 Votes"
LeonardHarris-3315 asked LeonardHarris-3315 edited

Multiple versions of same dependacy being referenced - how to resolve?

Got a slight problem here with multiple references of the same dependency - Dagger, I have a binding library that uses dagger and specific version, more specifically latest version, reason for this is a method was introduced that is being called from another dependency so I need that version, this was fine until I needed to include Xamarin.Firebase.Messaging and as such this also has a dependency on dagger i.e. Xamarin.Google.Dagger and its using a much earlier version and as such I am getting an exception at compile time because both Dagger references are being included...

csharp
 Type dagger.Binds is defined multiple times: obj\Debug\110\lp\3\jl\dagger-2.30.1.jar:dagger/Binds.class, obj\Debug\110\lp\91\jl\dagger.jar:dagger/Binds.class


How can I resolve this besides trying to use only one version of dagger since I need the latest in my binding library and I hardly change the version in firebase nuget being included.... please help


81459-capture2.png


dotnet-xamarin
capture2.png (40.8 KiB)
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Anybody have any ideas on this?

0 Votes 0 ·

Hi, LeonardHarris. Sorry for the late reply. When there are dlls that you don't want readily available, you could set build actions on the .jar or AAR files that are in there bindings library. First please review the build actions to understand how they perform. The simplest one for this scenario would be to make the Dagger an Embedded Jar. Another option would be to use Reference Jar that way C# bindings are not created for reference.

The related doc about Build Actions in Binding library: https://docs.microsoft.com/en-us/xamarin/android/platform/binding-java-library/#build-actions

0 Votes 0 ·

@JarvanZhang-MSFT Hi there, I got this working somehow.

The jar was set to build action embeddedJar and I set the default namespace to Xamarin.Google.Dagger so it would have the same namespace as the dagger included in the Xamarin.Firebase.Messaging, I figured only a single Xamarin.Google.Dagger.dll would be generated from both libraries when I built the project it that was the case. I Added in the binding library first and did a rebuild then added the Xamarin.Firebase.Messaging via nuget with a rebuild and it worked and the application worked with both the push token still working from Xamarin.Firebase.Messaging and the binding library the references the dagger binding library.

1 Vote 1 ·

0 Answers