You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Xamarin.AndroidX.Activity: androidx.compose.runtime.Immutable is defined multiple times #1341
VS 2026 18.1.1, .NET 10.0.101, workload 10.0.101.1
Description
Hello,
I have updated to the current version of Xamarin.Firebase.Messaging 125.0.1.1, which adds as transitive package Xamarin.AndroidX.Activity 1.12.2.1, (...) which adds as transitive packages:
The Release build with R8 code shrinker enabled is producing the following error:
1>MSBUILD : java.exe error JAVA0000: Type androidx.compose.runtime.Immutable is defined multiple times:
xamarin.androidx.compose.runtime.annotation.android
xamarin.androidx.compose.runtime.annotation.jvm
Thanks
Steps to Reproduce
New MAUI app with .NET 10
Update all the packages (MAUI related)
Add Xamarin.Firebase.Messaging
Set in project properties -> Application -> Android Targets -> Minimum Android Target Framework -> Android 6.0 (API 23)
changed the title [-]Xamarin.AndroidX.Activity: androidx.compose.runtime.Immutable is defined multiple time[/-][+]Xamarin.AndroidX.Activity: androidx.compose.runtime.Immutable is defined multiple times[/+]on Jan 9, 2026
In my case, I had a class library (which was actually importing the transitive packages) and my mobile project was importing the class library resulting in the error. What worked for me is adding the following in my class library project:
@RobTF Unfortunately that's how the ecosystem is and Microsoft will not/can't do anything about it.
You would see similar results while using Kotlin for an Android app. Google moves around types as they wish, causing dependencies hell for the next 20 years.
MAUI and 3rd libraries need to keep going forward to reduce the chance of this error happening, but it is what it is.
For now the only workaround is to pin versions and/or exclude assets from specific packages.
@jonathanpeppers what is the advantage of using these dependencies over of the *.jvm ones?
Ideally, I would not have to specify any Nuget packages that I don't use directly, shouldn't they be pulled implicitly as dependencies?
If I just specify Xamarin.AndroidX.Compose.Runtime.Annotation/1.10.3.1, I get this error:
MSBUILD : java.exe error JAVA0000:
Error in C:\Users\timop\.nuget\packages\xamarin.androidx.datastore.preferences.core.jvm\1.2.0.1\buildTransitive\ne
t10.0-android36.0\..\..\jar\androidx.datastore.datastore-preferences-core-jvm.jar:androidx/datastore/preferences/c
ore/AtomicBoolean.class:
Type androidx.datastore.preferences.core.AtomicBoolean is defined multiple times: C:\Users\timop\.nuget\packages\x
amarin.androidx.datastore.preferences.core.jvm\1.2.0.1\buildTransitive\net10.0-android36.0\..\..\jar\androidx.data
store.datastore-preferences-core-jvm.jar:androidx/datastore/preferences/core/AtomicBoolean.class, obj\Release\net1
0.0-android\lp\180\jl\classes.jar:androidx/datastore/preferences/core/AtomicBoolean.class
Compilation failed
java.lang.RuntimeException: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origi
n: C:\Users\timop\.nuget\packages\xamarin.androidx.datastore.preferences.core.jvm\1.2.0.1\buildTransitive\net10.0-
android36.0\..\..\jar\androidx.datastore.datastore-preferences-core-jvm.jar
androidx/datastore/preferences/core/AtomicBoolean.class
at com.android.tools.r8.internal.xv.a(R8_8.11.18_94248c9a6fd57686ded562f231d18f14e8923ad1fe977e99b974a9bf901c8a48
:131)
at com.android.tools.r8.R8.main(R8_8.11.18_94248c9a6fd57686ded562f231d18f14e8923ad1fe977e99b974a9bf901c8a48:5)
Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: C:\Users\timop
\.nuget\packages\xamarin.androidx.datastore.preferences.core.jvm\1.2.0.1\buildTransitive\net10.0-android36.0\..\..
\jar\androidx.datastore.datastore-preferences-core-jvm.jar:androidx/datastore/preferences/core/AtomicBoolean.class
at Version.fakeStackEntry(Version_8.11.18.java:0)
at com.android.tools.r8.P.a(R8_8.11.18_94248c9a6fd57686ded562f231d18f14e8923ad1fe977e99b974a9bf901c8a48:1)
at com.android.tools.r8.internal.xv.a(R8_8.11.18_94248c9a6fd57686ded562f231d18f14e8923ad1fe977e99b974a9bf901c8a48
:82)
at com.android.tools.r8.internal.xv.a(R8_8.11.18_94248c9a6fd57686ded562f231d18f14e8923ad1fe977e99b974a9bf901c8a48
:32)
at com.android.tools.r8.internal.xv.a(R8_8.11.18_94248c9a6fd57686ded562f231d18f14e8923ad1fe977e99b974a9bf901c8a48
:31)
at com.android.tools.r8.R8.b(R8_8.11.18_94248c9a6fd57686ded562f231d18f14e8923ad1fe977e99b974a9bf901c8a48:62)
at com.android.tools.r8.R8.a(R8_8.11.18_94248c9a6fd57686ded562f231d18f14e8923ad1fe977e99b974a9bf901c8a48:1658)
at com.android.tools.r8.internal.xv.a(R8_8.11.18_94248c9a6fd57686ded562f231d18f14e8923ad1fe977e99b974a9bf901c8a48
:118)
... 1 more
Caused by: com.android.tools.r8.internal.g: Type androidx.datastore.preferences.core.AtomicBoolean is defined mult
iple times: C:\Users\timop\.nuget\packages\xamarin.androidx.datastore.preferences.core.jvm\1.2.0.1\buildTransitive
\net10.0-android36.0\..\..\jar\androidx.datastore.datastore-preferences-core-jvm.jar:androidx/datastore/preference
s/core/AtomicBoolean.class, obj\Release\net10.0-android\lp\180\jl\classes.jar:androidx/datastore/preferences/core/
AtomicBoolean.class
at com.android.tools.r8.internal.yg0.a(R8_8.11.18_94248c9a6fd57686ded562f231d18f14e8923ad1fe977e99b974a9bf901c8a4
8:21)
at com.android.tools.r8.internal.O80.a(R8_8.11.18_94248c9a6fd57686ded562f231d18f14e8923ad1fe977e99b974a9bf901c8a4
8:54)
at com.android.tools.r8.internal.O80.a(R8_8.11.18_94248c9a6fd57686ded562f231d18f14e8923ad1fe977e99b974a9bf901c8a4
8:10)
at java.base/java.util.concurrent.ConcurrentHashMap.merge(ConcurrentHashMap.java:2056)
at com.android.tools.r8.internal.O80.a(R8_8.11.18_94248c9a6fd57686ded562f231d18f14e8923ad1fe977e99b974a9bf901c8a4
8:6)
at com.android.tools.r8.graph.z4$a.c(R8_8.11.18_94248c9a6fd57686ded562f231d18f14e8923ad1fe977e99b974a9bf901c8a48:
6)
at com.android.tools.r8.dex.c.a(R8_8.11.18_94248c9a6fd57686ded562f231d18f14e8923ad1fe977e99b974a9bf901c8a48:56)
at com.android.tools.r8.dex.c.a(R8_8.11.18_94248c9a6fd57686ded562f231d18f14e8923ad1fe977e99b974a9bf901c8a48:12)
at com.android.tools.r8.R8.a(R8_8.11.18_94248c9a6fd57686ded562f231d18f14e8923ad1fe977e99b974a9bf901c8a48:33)
at com.android.tools.r8.R8.c(R8_8.11.18_94248c9a6fd57686ded562f231d18f14e8923ad1fe977e99b974a9bf901c8a48:8)
at com.android.tools.r8.R8.a(R8_8.11.18_94248c9a6fd57686ded562f231d18f14e8923ad1fe977e99b974a9bf901c8a48:1657)
at com.android.tools.r8.internal.xv.a(R8_8.11.18_94248c9a6fd57686ded562f231d18f14e8923ad1fe977e99b974a9bf901c8a48
:28)
... 4 more
Directory 'obj\Release\net10.0-android\lp\180' is from 'androidx.datastore.datastore-preferences-core-android.aar'
.
Build failed with 1 error(s) and 1 warning(s) in 52.0s
I need to also add the Xamarin.AndroidX.DataStore.Preferences.Core one, then it builds.
The other dependencies I use in that particular app are just these:
Has worked OK ever since :-) Maybe someone knows which package has a dependency causing this transitive to be loaded in the first place and fix it somehow?
hth
Type androidx.core.animation.AnimatorKt$addListener$1 is defined multiple times: obj\Debug\net10.0-android36\lp\99\jl\classes.jar:androidx/core/animation/AnimatorKt$addListener$1.class, obj\Debug\net10.0-android36\lp\107\jl\classes.jar:androidx/core/animation/AnimatorKt$addListener$1.class
I also get this when trying to migrate to MAUI 11 Rc1:
(0,1): error JAVA0000: Error in C:\Users\Andre\.nuget\packages\xamarin.androidx.compose.runtime.annotation.android\1.12.1\buildTransitive\net10.0-android36.0\..\..\aar\runtime-annotation-android.aar:classes.jar:
Type androidx.compose.runtime.Immutable is defined multiple times: C:\Users\Andre\.nuget\packages\xamarin.androidx.compose.runtime.annotation.android\1.12.1\buildTransitive\net10.0-android36.0\..\..\aar\runtime-annotation-android.aar:classes.jar, C:\Users\Andre\.nuget\packages\xamarin.androidx.compose.runtime.annotation.jvm\1.12.1\buildTransitive\net10.0-android36.0\..\..\jar\runtime-annotation-jvm.jar:androidx/compose/runtime/Immutable.class
Compilation failed
java.lang.RuntimeException: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: C:\Users\Andre\.nuget\packages\xamarin.androidx.compose.runtime.annotation.android\1.12.1\buildTransitive\net10.0-android36.0\..\..\aar\runtime-annotation-android.aar
classes.jar
at com.android.tools.r8.internal.lw0.a(R8_9.1.31_ffb8f76e0cfe19f6a6aff10b55ad38bc82c7544bc91f5b7fd86bc80f9b2412e7:127)
at com.android.tools.r8.D8.main(R8_9.1.31_ffb8f76e0cfe19f6a6aff10b55ad38bc82c7544bc91f5b7fd86bc80f9b2412e7:5)
Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: C:\Users\Andre\.nuget\packages\xamarin.androidx.compose.runtime.annotation.android\1.12.1\buildTransitive\net10.0-android36.0\..\..\aar\runtime-annotation-android.aar:classes.jar
at Version.fakeStackEntry(Version_9.1.31.java:0)
at com.android.tools.r8.r0.a(R8_9.1.31_ffb8f76e0cfe19f6a6aff10b55ad38bc82c7544bc91f5b7fd86bc80f9b2412e7:1)
at com.android.tools.r8.internal.lw0.a(R8_9.1.31_ffb8f76e0cfe19f6a6aff10b55ad38bc82c7544bc91f5b7fd86bc80f9b2412e7:81)
at com.android.tools.r8.internal.lw0.a(R8_9.1.31_ffb8f76e0cfe19f6a6aff10b55ad38bc82c7544bc91f5b7fd86bc80f9b2412e7:32)
at com.android.tools.r8.internal.lw0.a(R8_9.1.31_ffb8f76e0cfe19f6a6aff10b55ad38bc82c7544bc91f5b7fd86bc80f9b2412e7:31)
at com.android.tools.r8.internal.lw0.b(R8_9.1.31_ffb8f76e0cfe19f6a6aff10b55ad38bc82c7544bc91f5b7fd86bc80f9b2412e7:2)
at com.android.tools.r8.D8.a(R8_9.1.31_ffb8f76e0cfe19f6a6aff10b55ad38bc82c7544bc91f5b7fd86bc80f9b2412e7:27)
at com.android.tools.r8.D8.b(R8_9.1.31_ffb8f76e0cfe19f6a6aff10b55ad38bc82c7544bc91f5b7fd86bc80f9b2412e7:23)
at com.android.tools.r8.D8.a(R8_9.1.31_ffb8f76e0cfe19f6a6aff10b55ad38bc82c7544bc91f5b7fd86bc80f9b2412e7:25)
at com.android.tools.r8.internal.lw0.a(R8_9.1.31_ffb8f76e0cfe19f6a6aff10b55ad38bc82c7544bc91f5b7fd86bc80f9b2412e7:114)
... 1 more
Caused by: com.android.tools.r8.internal.j: Type androidx.compose.runtime.Immutable is defined multiple times: C:\Users\Andre\.nuget\packages\xamarin.androidx.compose.runtime.annotation.android\1.12.1\buildTransitive\net10.0-android36.0\..\..\aar\runtime-annotation-android.aar:classes.jar, C:\Users\Andre\.nuget\packages\xamarin.androidx.compose.runtime.annotation.jvm\1.12.1\buildTransitive\net10.0-android36.0\..\..\jar\runtime-annotation-jvm.jar:androidx/compose/runtime/Immutable.class
at com.android.tools.r8.internal.yp3.a(R8_9.1.31_ffb8f76e0cfe19f6a6aff10b55ad38bc82c7544bc91f5b7fd86bc80f9b2412e7:21)
at com.android.tools.r8.internal.i83.a(R8_9.1.31_ffb8f76e0cfe19f6a6aff10b55ad38bc82c7544bc91f5b7fd86bc80f9b2412e7:68)
at com.android.tools.r8.internal.i83.a(R8_9.1.31_ffb8f76e0cfe19f6a6aff10b55ad38bc82c7544bc91f5b7fd86bc80f9b2412e7:16)
at java.base/java.util.concurrent.ConcurrentHashMap.merge(ConcurrentHashMap.java:2056)
at com.android.tools.r8.internal.i83.a(R8_9.1.31_ffb8f76e0cfe19f6a6aff10b55ad38bc82c7544bc91f5b7fd86bc80f9b2412e7:10)
at com.android.tools.r8.graph.v9$a.c(R8_9.1.31_ffb8f76e0cfe19f6a6aff10b55ad38bc82c7544bc91f5b7fd86bc80f9b2412e7:3)
at com.android.tools.r8.dex.c.a(R8_9.1.31_ffb8f76e0cfe19f6a6aff10b55ad38bc82c7544bc91f5b7fd86bc80f9b2412e7:57)
at com.android.tools.r8.dex.c.a(R8_9.1.31_ffb8f76e0cfe19f6a6aff10b55ad38bc82c7544bc91f5b7fd86bc80f9b2412e7:12)
at com.android.tools.r8.D8.a(R8_9.1.31_ffb8f76e0cfe19f6a6aff10b55ad38bc82c7544bc91f5b7fd86bc80f9b2412e7:34)
at com.android.tools.r8.D8.d(R8_9.1.31_ffb8f76e0cfe19f6a6aff10b55ad38bc82c7544bc91f5b7fd86bc80f9b2412e7:20)
at com.android.tools.r8.D8.c(R8_9.1.31_ffb8f76e0cfe19f6a6aff10b55ad38bc82c7544bc91f5b7fd86bc80f9b2412e7:8)
at com.android.tools.r8.internal.lw0.a(R8_9.1.31_ffb8f76e0cfe19f6a6aff10b55ad38bc82c7544bc91f5b7fd86bc80f9b2412e7:28)
... 6 more
this worked for me, too. I renamed the Xamarin.AndroidX.Compose.Runtime.Annotation.Android.targets in .nuget\packages\xamarin.androidx.compose.runtime.annotation.android\1.12.1\buildTransitive\net10.0-android36.0 and now it works. Thanks for the workaround 👍
Activity
[-]Xamarin.AndroidX.Activity: androidx.compose.runtime.Immutable is defined multiple time[/-][+]Xamarin.AndroidX.Activity: androidx.compose.runtime.Immutable is defined multiple times[/+]tipa commentedon Jan 10, 2026
Same issue here can also be reproduced by adding these two dependencies:
This issue can also be reproduced in a non-MAUI app (
dotnet new android)Pepsi1x1 commentedon Jan 11, 2026
Worked around with the following references
markuspalme commentedon Jan 12, 2026
experiencing the same issue with a MAUI app - please let me know if additional details would help finding the issue.
kerberosargos commentedon Jan 16, 2026
lesterbotello commentedon Jan 18, 2026
In my case, I had a class library (which was actually importing the transitive packages) and my mobile project was importing the class library resulting in the error. What worked for me is adding the following in my class library project:
More info: https://learn.microsoft.com/en-us/nuget/consume-packages/package-references-in-project-files#controlling-dependency-assets
RsZoli commentedon Jan 20, 2026
why is this problem so common for almost every version bump? :(
KRA2008 commentedon Jan 20, 2026
#764 ?
fix: exclude duplicate AndroidX Compose JVM package
dbSoft-SoftwareSolutions commentedon Jan 25, 2026
We have the same problem too
decv86 commentedon Feb 3, 2026
Same problem here
vpenades commentedon Feb 9, 2026
Same problem
RobTF commentedon Feb 9, 2026
It's absolutely ridiculous. We're sick to death of this stuff, you spend more time battling the tools and build process than adding business value.
dotMorten commentedon Feb 9, 2026
We also have customers hitting this too, and have a hard time finding a solid fix that'll "just work" no matter what version they are targeting.
dartasen commentedon Feb 10, 2026
@RobTF Unfortunately that's how the ecosystem is and Microsoft will not/can't do anything about it.
You would see similar results while using Kotlin for an Android app. Google moves around types as they wish, causing dependencies hell for the next 20 years.
MAUI and 3rd libraries need to keep going forward to reduce the chance of this error happening, but it is what it is.
For now the only workaround is to pin versions and/or exclude assets from specific packages.
4 remaining items
Fix duplicate class errors for runtime-annotation-jvm and datastore-p…
tipa commentedon Mar 3, 2026
When is this fix expected to be published? After the latest round of Nuget updates yesterday, I still get this error:
Manually adding this dependency resolves the issue (but
ExcludeAssets="all"is required):dbSoft-SoftwareSolutions commentedon Mar 3, 2026
We have the same problem too
jonathanpeppers commentedon Mar 3, 2026
The fix was in these packages (to stop depending on anything
*.jvm):@tipa are you able to use these?
They are still working on updating dotnet/maui with these, so they might uncover an issue.
tipa commentedon Mar 3, 2026
@jonathanpeppers what is the advantage of using these dependencies over of the
*.jvmones?Ideally, I would not have to specify any Nuget packages that I don't use directly, shouldn't they be pulled implicitly as dependencies?
jonathanpeppers commentedon Mar 3, 2026
If you specify Xamarin.AndroidX.Compose.Runtime.Annotation/1.10.3.1, it should prevent bringing in the duplicate
*.jvmpackage now.If that works for you, let me know.
We can do a step to add a
.1version to all packages, and you wouldn't have to list this one.tipa commentedon Mar 3, 2026
If I just specify
Xamarin.AndroidX.Compose.Runtime.Annotation/1.10.3.1, I get this error:I need to also add the
Xamarin.AndroidX.DataStore.Preferences.Coreone, then it builds.The other dependencies I use in that particular app are just these:
jonathanpeppers commentedon Mar 3, 2026
@tipa so you did get it to work, with a combination of latest packages?
We can bump all versions and realign, so you won't have to do that. Your top-level
<PackageReference/>would increment by0.0.0.1.tipa commentedon Mar 3, 2026
Yes, using both these two dependencies, the build appears to complete without error:
matteomonizza commentedon Mar 4, 2026
Same here
misterspeak commentedon Apr 3, 2026
I had this error and the cause was a file in a "buildtransitive" folder in my NuGet file cache (in my case p:\support\nugetpackages)
Look in this folder for
xamarin.androidx.compose.runtime.annotation.jvm\1.10.3\buildTransitive\net10.0-android36.0\Xamarin.AndroidX.Compose.Runtime.Annotation.Jvm.targetsand delete or rename it.
Has worked OK ever since :-) Maybe someone knows which package has a dependency causing this transitive to be loaded in the first place and fix it somehow?
hth
andrewleader commentedon Jun 14, 2026
Just sharing a THANK YOU, this issue seems to be fixed now! I used to have to have the following workaround in my project...
But after updating to the latest Xamarin libraries, I was able to remove those packages!
vpenades commentedon Jun 15, 2026
Sadly I'm still getting there errors:
with versions:
MagicAndre1981 commentedon Sep 22, 2026
I also get this when trying to migrate to MAUI 11 Rc1:
VS 2026 Insiders [12210.170]
MagicAndre1981 commentedon Sep 22, 2026
this worked for me, too. I renamed the
Xamarin.AndroidX.Compose.Runtime.Annotation.Android.targetsin.nuget\packages\xamarin.androidx.compose.runtime.annotation.android\1.12.1\buildTransitive\net10.0-android36.0and now it works. Thanks for the workaround 👍