Error when compiling if the Symbol.XamarinEMDK nuget is installed in more than two projects

// Expert user has replied.
S Sergio Lillo 2 years 2 months ago
85 3 0

I have a library called "Sample.Plugin" in which I have installed the nuget Symbol.XamarinEMDK with version 8.0.0.2 is a library that I use to obtain the serial of Zebra devices, so far everything is correct, the problem I have is that when I install my "Sample.Plugin" library in a Xamarin.Forms (Android) project in which I also have the Symbol.XamarinEMDK nuget installed with version 8.0.0.2 (the same version of Symbol.XamarinEMDK that is installed in the "Sample. Plugin") then a series of errors occurs that imply that there is a clash between the 2 Symbol.XamarinEMDK.

Removing the Symbol.XamarinEMDK nuget from my Xamarin.Forms (Android) project everything compiles fine, but I need the Symbol.XamarinEMDK to be installed both in my Xamarin.Forms (Android) project and in my Sample.Plugin library, but it seems that if it is installed in the 2 projects collide with each other, any suggestions why this happens?

And shows the following errors:
<code>
2&gt;MSBUILD : java.exe error JAVA0000: Info in obj\Debug\100\lp\1\jl\__reference__api3lib.jar:com/zebra/scannercontrol/SDKHandler.class:
2&gt;MSBUILD : java.exe error JAVA0000: Malformed inner-class attribute:
2&gt;MSBUILD : java.exe error JAVA0000: outerTypeInternal: com/zebra/scannercontrol/R
2&gt;MSBUILD : java.exe error JAVA0000: innerTypeInternal: com/zebra/rfid/api3/R$string
2&gt;MSBUILD : java.exe error JAVA0000: innerName: string
2&gt;MSBUILD : java.exe error JAVA0000:
2&gt;MSBUILD : java.exe error JAVA0000: Error in obj\Debug\100\lp\1\jl\__reference__classes.jar:com/symbol/emdk/EMDKBase.class:
2&gt;MSBUILD : java.exe error JAVA0000: Type com.symbol.emdk.EMDKBase is defined multiple times: obj\Debug\100\lp\1\jl\__reference__classes.jar:com/symbol/emdk/EMDKBase.class, obj\Debug\100\lp\6\jl\com.symbol.emdk.jar:com/symbol/emdk/EMDKBase.class
2&gt;MSBUILD : java.exe error JAVA0000: Compilation failed
2&gt;MSBUILD : java.exe error JAVA0000: java.lang.RuntimeException: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: obj\Debug\100\lp\1\jl\__reference__classes.jar
2&gt;MSBUILD : java.exe error JAVA0000: com/symbol/emdk/EMDKBase.class
2&gt;MSBUILD : java.exe error JAVA0000: at com.android.tools.r8.internal.Bj.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:98)
2&gt;MSBUILD : java.exe error JAVA0000: at com.android.tools.r8.D8.main(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:4)
2&gt;MSBUILD : java.exe error JAVA0000: Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: obj\Debug\100\lp\1\jl\__reference__classes.jar:com/symbol/emdk/EMDKBase.class
2&gt;MSBUILD : java.exe error JAVA0000: at Version.fakeStackEntry(Version_3.3.28.java:0)
2&gt;MSBUILD : java.exe error JAVA0000: at com.android.tools.r8.internal.Bj.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:75)
2&gt;MSBUILD : java.exe error JAVA0000: at com.android.tools.r8.internal.Bj.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:28)
2&gt;MSBUILD : java.exe error JAVA0000: at com.android.tools.r8.internal.Bj.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:27)
2&gt;MSBUILD : java.exe error JAVA0000: at com.android.tools.r8.internal.Bj.b(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:2)
2&gt;MSBUILD : java.exe error JAVA0000: at com.android.tools.r8.D8.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:22)
2&gt;MSBUILD : java.exe error JAVA0000: at com.android.tools.r8.D8.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:17)
2&gt;MSBUILD : java.exe error JAVA0000: at com.android.tools.r8.internal.Bj.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:85)
2&gt;MSBUILD : java.exe error JAVA0000: ... 1 more
2&gt;MSBUILD : java.exe error JAVA0000: Caused by: com.android.tools.r8.internal.f: Type com.symbol.emdk.EMDKBase is defined multiple times: obj\Debug\100\lp\1\jl\__reference__classes.jar:com/symbol/emdk/EMDKBase.class, obj\Debug\100\lp\6\jl\com.symbol.emdk.jar:com/symbol/emdk/EMDKBase.class
2&gt;MSBUILD : java.exe error JAVA0000: at com.android.tools.r8.internal.DT.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:14)
2&gt;MSBUILD : java.exe error JAVA0000: at com.android.tools.r8.internal.DT.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:22)
2&gt;MSBUILD : java.exe error JAVA0000: at com.android.tools.r8.internal.CN.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:33)
2&gt;MSBUILD : java.exe error JAVA0000: at com.android.tools.r8.internal.CN.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:10)
2&gt;MSBUILD : java.exe error JAVA0000: at java.base/java.util.concurrent.ConcurrentHashMap.merge(ConcurrentHashMap.java:2048)
2&gt;MSBUILD : java.exe error JAVA0000: at com.android.tools.r8.internal.CN.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:6)
2&gt;MSBUILD : java.exe error JAVA0000: at com.android.tools.r8.graph.B2$a.e(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:4)
2&gt;MSBUILD : java.exe error JAVA0000: at com.android.tools.r8.dex.b.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:105)
2&gt;MSBUILD : java.exe error JAVA0000: at com.android.tools.r8.dex.b.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:28)
2&gt;MSBUILD : java.exe error JAVA0000: at com.android.tools.r8.D8.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:25)
2&gt;MSBUILD : java.exe error JAVA0000: at com.android.tools.r8.D8.d(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:606)
2&gt;MSBUILD : java.exe error JAVA0000: at com.android.tools.r8.D8.c(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:1)
2&gt;MSBUILD : java.exe error JAVA0000: at com.android.tools.r8.internal.Bj.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:24)
2&gt;MSBUILD : java.exe error JAVA0000: ... 5 more
2&gt;MSBUILD : java.exe error JAVA0000: Directory 'obj\Debug\100\lp\1' is from 'Sample. Plugin.Core.dll'.
</code>

Please Register or Login to post a reply

3 Replies

J James Swinton-Bland

Hi,

I think this is down to the architecture of your library / application. I would probably suggest extending the functionality of your plugin library to include the Forms project requirements. E.g. if you need to access the scanner via the EMDK in your forms app, re-architect your project so that the scanner logic is in the library (or vice versa) so that you only need a single EMDK in your application.

Alternatively, there may be some way to access the dependency from the Forms project via the plugin library, but I'm not that familiar with Xamarin so that is just a guess.

Thanks,

James

S Sergio Lillo

The example that I have raised above is a more basic architecture than the one that we have actually assembled but I had put it so that the problem could be understood in a simpler way. We actually have several nugets: Serial.Plugin (EMDK dependency), Updater.Plugin (EMDK dependency), Scanner.Plugin (EMDK dependency) and then we have the Xamarin.Forms project in this Android case where if we install these 3 nugets at the same time (all 3 have the EMDK as a dependency), this is where the aforementioned error occurs. So in this case the solution you mention is not optimal because at the architecture level it would not make sense to make a single giant plugin that includes the serial, the updater and the scanner. Does it really make sense for the EMDK to collide with each other if it depends on several different nugets? I say this because it is the only case that I have found in which an SDK cannot be as a dependency of several nugets at the same time.

J James Swinton-Bland

In that case, if you don't want to modify anything, maybe excluding dependencies may resolve the conflict: https://learn.microsoft.com/en-us/nuget/concepts/dependency-resolution#…

Edit: Sorry, I've corrected the link.

CONTACT
Can’t find what you’re looking for?