Skip to content

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

Closed

Description

@sk1llsh0t

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

Activity

  1. 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[/+] on Oct 18, 2023
  2. andersonvieiragomeslopes commented on Oct 20, 2023

    @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.

  3. sk1llsh0t commented on Oct 20, 2023

    @sk1llsh0t
    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.

  4. andersonvieiragomeslopes commented on Oct 21, 2023

    @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

  5. moljac commented on Oct 23, 2023

    @moljac
    Contributor

    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.

  6. czmirek commented on Oct 23, 2023

    @czmirek

    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" />
    
  7. moljac commented on Oct 23, 2023

    @moljac
    Contributor

    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

  8. moljac commented on Oct 23, 2023

    @moljac
    Contributor
  9. sk1llsh0t commented on Oct 23, 2023

    @sk1llsh0t
    Author

    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>

  10. moljac commented on Oct 23, 2023

    @moljac
    Contributor

    @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.

  11. sk1llsh0t commented on Oct 23, 2023

    @sk1llsh0t
    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!

  12. moljac commented on Oct 23, 2023

    @moljac
    Contributor

    Workaround found.
    Closing this issue

  13. uSafi commented on Nov 26, 2023

    @uSafi

    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" />
    
  14. moljac commented on Nov 26, 2023

    @moljac
    Contributor

    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.

  15. uSafi commented on Nov 27, 2023

    @uSafi

    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

  16. gautambjain commented on Apr 3, 2024

    @gautambjain

    @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

  17. uSafi commented on Apr 3, 2024

    @uSafi

    @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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions