2

I'm migrating a Xamarin.Forms app into .NET MAUI and after fixing various issues and errors, last of which was solved by adding two references:

  • Xamarin.AndroidX.Collection
  • Xamarin.AndroidX.Collection.Ktx

as suggested here, which seemed to help solve a very similar looking JAVA error, but made another pop up:

Error   JAVA0000    Error in obj\Debug\net8.0-android\lp\141\jl\classes.jar:android/support/v4/app/INotificationSideChannel$Stub.class:
Type android.support.v4.app.INotificationSideChannel$Stub is defined multiple times: obj\Debug\net8.0-android\lp\141\jl\classes.jar:android/support/v4/app/INotificationSideChannel$Stub.class, obj\Debug\net8.0-android\lp\28\jl\bin\classes.jar:android/support/v4/app/INotificationSideChannel$Stub.class
Compilation failed
java.lang.RuntimeException: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: obj\Debug\net8.0-android\lp\141\jl\classes.jar
android/support/v4/app/INotificationSideChannel$Stub.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: obj\Debug\net8.0-android\lp\141\jl\classes.jar:android/support/v4/app/INotificationSideChannel$Stub.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 android.support.v4.app.INotificationSideChannel$Stub is defined multiple times: obj\Debug\net8.0-android\lp\141\jl\classes.jar:android/support/v4/app/INotificationSideChannel$Stub.class, obj\Debug\net8.0-android\lp\28\jl\bin\classes.jar:android/support/v4/app/INotificationSideChannel$Stub.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
Directory 'obj\Debug\net8.0-android\lp\141' is from 'androidx.core.core.aar'.   ARC.Mobile.Android      1   

The very end of the error suggests still an issue with AndroidX dependencies, but I'm fairly clueless here.

EDIT: My package references are as follows:

<PackageReference Include="CommunityToolkit.Maui.Markup" Version="4.0.0" />
<PackageReference Include="Controls.UserDialogs.Maui" Version="1.5.4" />
<PackageReference Include="IdentityModel.OidcClient" Version="6.0.0" />
<PackageReference Include="Syncfusion.Maui.Core" Version="26.1.35" />
<PackageReference Include="Xamarin.AndroidX.Collection" Version="1.4.0.4" />
<PackageReference Include="Xamarin.AndroidX.Collection.Ktx" Version="1.4.0.3" />
<PackageReference Include="Xamarin.Azure.NotificationHubs.Android" Version="1.1.4.1" />
<PackageReference Include="Xamarin.Google.Dagger" Version="2.49.0.1" />
<PackageReference Include="Xamarin.GooglePlayServices.Base" Version="118.3.0.1" />
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.40" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.40" />

2 Answers 2

4

I ran into the same issue while using this OCR plugin. Are you seeing this because of a plugin you're using?

What resolved it was to add a reference to Xamarin.AndroidX.Collection.Ktx directly. So add:

<PackageReference Include="Xamarin.AndroidX.Fragment.Ktx" Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">
    <Version>1.6.2.2</Version>
</PackageReference>

to your csproj file. I see that for you the mentioned type is a bit different so it might be another dependency for you, you'll have to play with that.

Make sure that you're using the latest versions of all the dependencies you have, I think it has to do with using older versions.

Sign up to request clarification or add additional context in comments.

Comments

2

This is sticky issue where different cases are kept, so users can get a feeling how work around this class of issues:

https://github.com/xamarin/AndroidX/issues/764

In your case try explicitly adding:

<PackageReference Include="Xamarin.AndroidX.Core" Version="1.13.1.1" />
<PackageReference Include="Xamarin.AndroidX.Legacy.Support.V4" Version="1.0.0.25" />

If that does not help I will need list of your PaxkageReferences

2 Comments

I updated the question with the list of package references. When I add the two ones you mention I am now getting this instead: Caused by: com.android.tools.r8.utils.b: Type androidx.activity.ActivityViewModelLazyKt$viewModels$1 is defined multiple times. It's like a rabbit hole
Well I cannot edit all older answers/comments... Those versions are 10 months old. Simply replace version in the sample with latest version[s]. Please visit: nuget.org/packages/Xamarin.AndroidX.Core/#versions-body-tab nuget.org/packages/… Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.