Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NET8 (MAUI)] Multiple Definitions Error In Xamarin.AndroidX.Work.Runtime 2.8.1.5 #800

Closed
sk1llsh0t opened this issue Oct 18, 2023 · 16 comments

Comments

@sk1llsh0t
Copy link

sk1llsh0t commented Oct 18, 2023

Android application type

Android for .NET (net8.0-android)

Affected platform version

VS for Mac 2022 17.6.5, .NET 8.0 (8.0.100-rc.2.23502.2), MAUI, net8.0-android

Description

In my Xamarin Forms app, I use the WorkManager class to create background Work objects to execute long running tasks. I am in the middle of converting our application over to .NET 8.0 and MAUI. When I try to build the application, I get the following error.

Error in /Users/e071324/.nuget/packages/xamarin.androidx.collection.jvm/1.3.0.1/buildTransitive/net6.0-android31.0/../../jar/androidx.collection.collection-jvm.jar:androidx/collection/ArraySetKt.class: Type androidx.collection.ArraySetKt is defined multiple times: /Users/e071324/.nuget/packages/xamarin.androidx.collection.jvm/1.3.0.1/buildTransitive/net6.0-android31.0/../../jar/androidx.collection.collection-jvm.jar:androidx/collection/ArraySetKt.class, /Users/e071324/.nuget/packages/xamarin.androidx.collection.ktx/1.2.0.9/buildTransitive/net6.0-android31.0/../../jar/androidx.collection.collection-ktx.jar:androidx/collection/ArraySetKt.class Compilation failed Exception in thread "main" java.lang.RuntimeException: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: /Users/e071324/.nuget/packages/xamarin.androidx.collection.jvm/1.3.0.1/buildTransitive/net6.0-android31.0/../../jar/androidx.collection.collection-jvm.jar:androidx/collection/ArraySetKt.class at com.android.tools.r8.utils.R0.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:126) at com.android.tools.r8.D8.main(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:5) Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: /Users/e071324/.nuget/packages/xamarin.androidx.collection.jvm/1.3.0.1/buildTransitive/net6.0-android31.0/../../jar/androidx.collection.collection-jvm.jar:androidx/collection/ArraySetKt.class at Version.fakeStackEntry(Version_8.1.56.java:0) at com.android.tools.r8.M.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:5) at com.android.tools.r8.utils.R0.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:81) at com.android.tools.r8.utils.R0.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:32) at com.android.tools.r8.utils.R0.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:31) at com.android.tools.r8.utils.R0.b(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:2) at com.android.tools.r8.D8.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:26) at com.android.tools.r8.D8.b(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:13) at com.android.tools.r8.D8.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:24) at com.android.tools.r8.utils.R0.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:113) ... 1 more Caused by: com.android.tools.r8.utils.b: Type androidx.collection.ArraySetKt is defined multiple times: /Users/e071324/.nuget/packages/xamarin.androidx.collection.jvm/1.3.0.1/buildTransitive/net6.0-android31.0/../../jar/androidx.collection.collection-jvm.jar:androidx/collection/ArraySetKt.class, /Users/e071324/.nuget/packages/xamarin.androidx.collection.ktx/1.2.0.9/buildTransitive/net6.0-android31.0/../../jar/androidx.collection.collection-ktx.jar:androidx/collection/ArraySetKt.class at com.android.tools.r8.utils.O2.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:21) at com.android.tools.r8.utils.O2.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:26) at com.android.tools.r8.utils.A2.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:44) at com.android.tools.r8.utils.A2.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:10) at java.base/java.util.concurrent.ConcurrentHashMap.merge(ConcurrentHashMap.java:2056) at com.android.tools.r8.utils.A2.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:6) at com.android.tools.r8.graph.b4$a.e(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:7) at com.android.tools.r8.dex.c.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:58) at com.android.tools.r8.dex.c.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:9) at com.android.tools.r8.dex.c.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:8) at com.android.tools.r8.D8.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:29) at com.android.tools.r8.D8.d(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:17) at com.android.tools.r8.D8.c(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:1) at com.android.tools.r8.utils.R0.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:28) ... 6 more

If I remove the workmanager/work objects and the Xamarin.AndroidX.Work.Runtime 2.8.1.5 nuget package, my application compiles.

Steps to Reproduce

  1. Create a new MAUI project using .NET 8.0 (8.0.100-rc.2.23502.2)
  2. Add the Xamarin.AndroidX.Work.Runtime 2.8.1.5 (latest)
  3. Build the solution and observe the error

Did you find any workaround?

No workaround as of right now.

Relevant log output

No response

@sk1llsh0t sk1llsh0t changed the title [NET7 to NET8 (MAUI)] Multiple Definitions Error In Xamarin.AndroidX.Work.Runtime 2.8.1.5 [NET8 (MAUI)] Multiple Definitions Error In Xamarin.AndroidX.Work.Runtime 2.8.1.5 Oct 18, 2023
@andersonvieiragomeslopes
Copy link

andersonvieiragomeslopes commented Oct 20, 2023

Hi @sk1llsh0t

I have the same problem, did you find any workaround?

I have target net 8.0-android34 and it doesn't work either.

@sk1llsh0t
Copy link
Author

Hi @sk1llsh0t

I have the same problem, did you find any workaround?

I have target net 8.0-android34 and it doesn't work either

No workaround yet. Waiting for one of the maintainers to take a look and provide a fix.

@andersonvieiragomeslopes

Hi @sk1llsh0t
I have the same problem, did you find any workaround?
I have target net 8.0-android34 and it doesn't work either

No workaround yet. Waiting for one of the maintainers to take a look and provide a fix.

This problem stopped my project @jonathanpeppers

@moljac
Copy link
Contributor

moljac commented Oct 23, 2023

Thanks for the feedback, but read #764 first.

Possible duplicate.

@andersonvieiragomeslopes Why mentioning JonathanPeppers??

Without list of PackageReferences in this case not much help can be provided.

@czmirek
Copy link

czmirek commented Oct 23, 2023

Fixed this error in my project by directly installing the following NuGets:

<PackageReference Include="Xamarin.AndroidX.Collection" Version="1.3.0.1" />
<PackageReference Include="Xamarin.AndroidX.Collection.Ktx" Version="1.3.0.1" />

@moljac
Copy link
Contributor

moljac commented Oct 23, 2023

Fixed this error in my project by directly installing the following NuGets:

<PackageReference Include="Xamarin.AndroidX.Collection" Version="1.3.0.1" />
<PackageReference Include="Xamarin.AndroidX.Collection.Ktx" Version="1.3.0.1" />

Yes. Usually explicitly overriding transitive dependencies helps. The problem is to determine which transitive dependencies.

Anyhow @czmirek thanks a lot for feedback

@moljac
Copy link
Contributor

moljac commented Oct 23, 2023

Related:

dotnet/maui#18118

@sk1llsh0t
Copy link
Author

sk1llsh0t commented Oct 23, 2023

Without list of PackageReferences in this case not much help can be provided.

Here you go (minus the reference to the androidx package):

<ItemGroup> <PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" /> <PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiVersion)" /> <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0-rc.2.23479.6" /> </ItemGroup>

@moljac
Copy link
Contributor

moljac commented Oct 23, 2023

@sk1llsh0t

Thanks

(minus the reference to the androidx package):

I need those too. Those are the culprit of the problem. Try removing those and you'll see the error is gone.

@sk1llsh0t
Copy link
Author

Removing those packages bring other runtime and compile time errors.

The only thing that worked for me was following @czmirek comment above. I'll stick with this until we have a long term solution.

Thanks!

@moljac
Copy link
Contributor

moljac commented Oct 23, 2023

Workaround found.
Closing this issue

@moljac moljac closed this as completed Oct 23, 2023
@uSafi
Copy link

uSafi commented Nov 26, 2023

I have the same problem, and those packages you guys mentioned are as of now not compatible with .net 8 LTS, and I don't have a workaround yet.

<PackageReference Include="Xamarin.AndroidX.Collection" Version="1.3.0.1" />
<PackageReference Include="Xamarin.AndroidX.Collection.Ktx" Version="1.3.0.1" />

@moljac
Copy link
Contributor

moljac commented Nov 26, 2023

I have the same problem, and those packages you guys mentioned are as of now not compatible with .net 8 RTL,

It has nothing to do with .NET 8, but package dependencies (NuGet - Maven mapping).

and I don't have a workaround yet.

In order to find workaround list your <PackageReference>s here, so I can analyze, please.

@uSafi
Copy link

uSafi commented Nov 27, 2023

I have the same problem, and those packages you guys mentioned are as of now not compatible with .net 8 RTL,

It has nothing to do with .NET 8, but package dependencies (NuGet - Maven mapping).

and I don't have a workaround yet.

In order to find workaround list your <PackageReference>s here, so I can analyze, please.

Thanks for replying. here's the list of Package References in my project, and a screenshot of the error.

<ItemGroup>
  <PackageReference Include="AsyncAwaitBestPractices" Version="7.0.0" />
  <PackageReference Include="CommunityToolkit.Maui" Version="7.0.0" />
  <PackageReference Include="CommunityToolkit.MVVM" Version="8.2.2" />
  <PackageReference Include="FirebaseDatabase.net" Version="4.2.0" />
  <PackageReference Include="FirebaseStorage.net" Version="1.0.3" />
  <PackageReference Include="Magick.NET-Q16-AnyCPU" Version="13.4.0" />
  <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
  <PackageReference Include="Plugin.LocalNotification" Version="10.1.8" />
  <PackageReference Include="sqlite-net-pcl" Version="1.8.116" />
  <PackageReference Include="SQLitePCLRaw.bundle_green" Version="2.1.7" />
  <PackageReference Include="SQLitePCLRaw.provider.dynamic_cdecl" Version="2.1.7" />
  <PackageReference Include="Syncfusion.Maui.Core" Version="23.2.5" />
</ItemGroup>


<ItemGroup Condition="'$(TargetFramework)' == 'net8.0-android'">
	<PackageReference Include="Xamarin.Firebase.Auth">
		<Version>122.2.0</Version>
	</PackageReference>
</ItemGroup>

Screenshot 2023-11-27 150244

@gautambjain
Copy link

@uSafi - Please install those packages (latest version) explicitly into your project. It should work. It just worked for me. I am using .Net 8.

The packages are - Xamarin.AndroidX.Collection and Xamarin.AndroidX.Collection.Ktx

@uSafi
Copy link

uSafi commented Apr 3, 2024

@uSafi - Please install those packages (latest version) explicitly into your project. It should work. It just worked for me. I am using .Net 8.

The packages are Xamarin.AndroidX.Collection and Xamarin.AndroidX.Collection.Ktx

Thank you, but back then, in my case, the package Xamarin.AndroidX.Fragment.Ktx worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants