Repository navigation
Closed
Description
Android application type
Classic Xamarin.Android (MonoAndroid12.0, etc.)
Affected platform version
Visual Studio 2022 Enterprise, Windows 11, Xamarin.Android, build tools Android 13
Description
Upgrading packages Xamarin.AndroidX.Lifecycle.Runtime from previous version to 2.6.1 causes a Java error:
Error in G:\NuGET\Packages\xamarin.androidx.lifecycle.common\2.6.1\buildTransitive\monoandroid12.0\..\..\jar\androidx.lifecycle.lifecycle-common.jar:androidx/lifecycle/DispatchQueue.class:
Type androidx.lifecycle.DispatchQueue is defined multiple times: G:\NuGET\Packages\xamarin.androidx.lifecycle.common\2.6.1\buildTransitive\monoandroid12.0\..\..\jar\androidx.lifecycle.lifecycle-common.jar:androidx/lifecycle/DispatchQueue.class, obj\Debug\130\lp\150\jl\classes.jar:androidx/lifecycle/DispatchQueue.class
Compilation failed
This will happen also if the update is triggered by updating another NuGet packaged that have a dependecy on Lifecycle packages, like Xamarin.AndroidX.Fragment
Steps to Reproduce
Open solution NuGet packages, then upgrade Lifecycle related packages.
Did you find any workaround?
Just to not update the NuGet packges makes the solution work again.
Relevant log output
Error in G:\NuGET\Packages\xamarin.androidx.lifecycle.common\2.6.1\buildTransitive\monoandroid12.0\..\..\jar\androidx.lifecycle.lifecycle-common.jar:androidx/lifecycle/DispatchQueue.class:
Type androidx.lifecycle.DispatchQueue is defined multiple times: G:\NuGET\Packages\xamarin.androidx.lifecycle.common\2.6.1\buildTransitive\monoandroid12.0\..\..\jar\androidx.lifecycle.lifecycle-common.jar:androidx/lifecycle/DispatchQueue.class, obj\Debug\130\lp\150\jl\classes.jar:androidx/lifecycle/DispatchQueue.class
Compilation failed
java.lang.RuntimeException: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: G:\NuGET\Packages\xamarin.androidx.lifecycle.common\2.6.1\buildTransitive\monoandroid12.0\..\..\jar\androidx.lifecycle.lifecycle-common.jar
androidx/lifecycle/DispatchQueue.class
at com.android.tools.r8.internal.Fj.a(R8_3.3.75_b7a6ff6b13548611571508fe72282c9167faa649161ca0013edfc92e19bd7e58:98)
at com.android.tools.r8.D8.main(R8_3.3.75_b7a6ff6b13548611571508fe72282c9167faa649161ca0013edfc92e19bd7e58:4)
Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: G:\NuGET\Packages\xamarin.androidx.lifecycle.common\2.6.1\buildTransitive\monoandroid12.0\..\..\jar\androidx.lifecycle.lifecycle-common.jar:androidx/lifecycle/DispatchQueue.class
at Version.fakeStackEntry(Version_3.3.75.java:0)
at com.android.tools.r8.internal.Fj.a(R8_3.3.75_b7a6ff6b13548611571508fe72282c9167faa649161ca0013edfc92e19bd7e58:75)
at com.android.tools.r8.internal.Fj.a(R8_3.3.75_b7a6ff6b13548611571508fe72282c9167faa649161ca0013edfc92e19bd7e58:28)
at com.android.tools.r8.internal.Fj.a(R8_3.3.75_b7a6ff6b13548611571508fe72282c9167faa649161ca0013edfc92e19bd7e58:27)
at com.android.tools.r8.internal.Fj.b(R8_3.3.75_b7a6ff6b13548611571508fe72282c9167faa649161ca0013edfc92e19bd7e58:2)
at com.android.tools.r8.D8.a(R8_3.3.75_b7a6ff6b13548611571508fe72282c9167faa649161ca0013edfc92e19bd7e58:22)
at com.android.tools.r8.D8.a(R8_3.3.75_b7a6ff6b13548611571508fe72282c9167faa649161ca0013edfc92e19bd7e58:17)
at com.android.tools.r8.internal.Fj.a(R8_3.3.75_b7a6ff6b13548611571508fe72282c9167faa649161ca0013edfc92e19bd7e58:85)
... 1 more
Caused by: com.android.tools.r8.internal.f: Type androidx.lifecycle.DispatchQueue is defined multiple times: G:\NuGET\Packages\xamarin.androidx.lifecycle.common\2.6.1\buildTransitive\monoandroid12.0\..\..\jar\androidx.lifecycle.lifecycle-common.jar:androidx/lifecycle/DispatchQueue.class, obj\Debug\130\lp\150\jl\classes.jar:androidx/lifecycle/DispatchQueue.class
at com.android.tools.r8.internal.JT.a(R8_3.3.75_b7a6ff6b13548611571508fe72282c9167faa649161ca0013edfc92e19bd7e58:14)
at com.android.tools.r8.internal.JT.a(R8_3.3.75_b7a6ff6b13548611571508fe72282c9167faa649161ca0013edfc92e19bd7e58:22)
at com.android.tools.r8.internal.HN.a(R8_3.3.75_b7a6ff6b13548611571508fe72282c9167faa649161ca0013edfc92e19bd7e58:33)
at com.android.tools.r8.internal.HN.a(R8_3.3.75_b7a6ff6b13548611571508fe72282c9167faa649161ca0013edfc92e19bd7e58:10)
at java.base/java.util.concurrent.ConcurrentHashMap.merge(ConcurrentHashMap.java:2048)
at com.android.tools.r8.internal.HN.a(R8_3.3.75_b7a6ff6b13548611571508fe72282c9167faa649161ca0013edfc92e19bd7e58:6)
at com.android.tools.r8.graph.B2$a.e(R8_3.3.75_b7a6ff6b13548611571508fe72282c9167faa649161ca0013edfc92e19bd7e58:4)
at com.android.tools.r8.dex.b.a(R8_3.3.75_b7a6ff6b13548611571508fe72282c9167faa649161ca0013edfc92e19bd7e58:110)
at com.android.tools.r8.dex.b.a(R8_3.3.75_b7a6ff6b13548611571508fe72282c9167faa649161ca0013edfc92e19bd7e58:28)
at com.android.tools.r8.D8.a(R8_3.3.75_b7a6ff6b13548611571508fe72282c9167faa649161ca0013edfc92e19bd7e58:25)
at com.android.tools.r8.D8.d(R8_3.3.75_b7a6ff6b13548611571508fe72282c9167faa649161ca0013edfc92e19bd7e58:606)
at com.android.tools.r8.D8.c(R8_3.3.75_b7a6ff6b13548611571508fe72282c9167faa649161ca0013edfc92e19bd7e58:1)
at com.android.tools.r8.internal.Fj.a(R8_3.3.75_b7a6ff6b13548611571508fe72282c9167faa649161ca0013edfc92e19bd7e58:24)
... 5 more
Directory 'obj\Debug\130\lp\150' is from 'androidx.lifecycle.lifecycle-runtime-ktx.aar'.Reacted by lexboss777, wiebesteven, Ladislav Čapka, jmh, Bozo Despotovic, Trevor Balcom, wfhm, Timo Partl and Alvaro Rivoir
Metadata
Metadata
Assignees
Labels
No labels
Activity
moljac commentedon Apr 13, 2023
Thanks for reporting. Do you have repro sample or at least
<PackageReference>listtbalcom commentedon Apr 19, 2023
I'm seeing the same
DispatchQueueerror while attempting to update Xamarin.AndroidX.Work.Runtime from 2.7.1.6 to 2.8.1. Here is my<PackageReference>list for the Android project:XDarinor commentedon Apr 19, 2023
I'm sorry for the late answer. I don't have a repro sample, but I can share the PackageReferences below:
Do you think this is enough? What also is needed?
moljac commentedon Apr 20, 2023
@XDarinor @tbalcom
Thanks for the lists. I will try to make repro sample[s] out of those.
moljac commentedon Apr 20, 2023
It is OK. Thanks
I hope so. Usually it is versions mismatch of the transitive dependencies.
moljac commentedon Apr 21, 2023
possibly related
#634
xamarin/GooglePlayServicesComponents#694
moljac commentedon Apr 21, 2023
Workaround to test
xamarin/GooglePlayServicesComponents#694 (comment)
tbalcom commentedon Apr 21, 2023
The workaround didn't help. I've also tried explicitly referencing the latest Xamarin.AndroidX.Lifecycle (Common, Common.Java8, Extensions) packages with no success.
tbalcom commentedon Apr 21, 2023
The full error:
moljac commentedon Apr 24, 2023
@XDarinor
This is big problem:
Android support libraries are not supported anymore.
XDarinor commentedon Apr 24, 2023
Mmm this could be a great issue. I think this package could be needed for the Syncfusion Treeview. I will try tomorrow to remove it and see if everything works out.
moljac commentedon Apr 25, 2023
@XDarinor
I'm not telling this is the root cause, but Android Support causes issues with modern apps which use AndroidX.
Could be. Try updating Treeview. Though I think you should not need to add some dependency for Treeview manually.
Or try removing
Xamarin.Android.Support.v7.RecyclerViewand see what screams with errors.Great.
wfhm commentedon Apr 26, 2023
Same here. Visual Studio for Mac 17.5.3 (build 15), MAUI net7.0 app.
Package reference list:
It's a fresh project so I wasn't updating
Xamarin.AndroidX.Work.Runtime, just added the 2.7.1.5 version. The workaround didn't help.Directory 'obj/Debug/net7.0-android/lp/173' is from 'androidx.lifecycle.lifecycle-runtime-ktx.aar' (double-checked it with map.cache).
tipa commentedon Apr 26, 2023
The problem can be easily reproduced by simply adding these two dependencies:
AndroidApp1.zip
15 remaining items
moljac commentedon May 12, 2023
Closing this issue
sphix0108 commentedon May 16, 2023
Hi,
I encountered the similar problem with: Type androidx.lifecycle.DispatchQueue is defined mutiple times.
How to check the dependencies that causes the error?
moljac commentedon May 16, 2023
Just update all dependencies to latest. Note: GPS-FB-MLKit or other 3rd party package might still cause issues. Namely GPS-FB-MLKit is not yet "aligned", so particular dependency could pull in problematic older packages and issue could be hit again.
It is not that easy. In some cases
Xamarin.AndroidX.Lifecycle.*, but in other cases combination of any could cause problems (check tipa's dependencies in this issue).sphix0108 commentedon May 19, 2023
Thanks for your reply.
I am trying to use Xamarin.AndroidX.Biometric <= this one is culprit but I don't know how to/ which dependencies should be upgrade together with it. I am fairly new to MAUI/Xamarin and development in all.
If you have any suggestion, it will be very helpful. Thanks
sphix0108 commentedon May 19, 2023
I tried downgraded the the Xamarin.AndroidX.BioMetric and *.AndroidX.Core to the previous level (Biometric = 1.1.0.10 & Core = 1.8.0.1) then I can build the project successfully. Just for a report, since my project is approaching deadline, I cannot check more regarding this problem.
Thank you for your support.
downgrade package due to dotnet/android-libraries#717
Move to .NET 8 and minor fixes (#9)
moljac commentedon May 24, 2023
Duplicate
xamarin/GooglePlayServicesComponents#775
Lsdenis commentedon May 31, 2023
Possible Workaround
I had a similar problem, but with another packages. So, basically this thread helped to understand the root of the problem.
Problem:
I went into the both paths
obj/Debug/net6.0-android33.0/lp/111/jl/andobj/Debug/net6.0-android33.0/lp/143/jl/, checked the manifests inside and installed both libraries explicitly.In my case they are:
I performed a quick smoke test and looks like it work, but no guarantee yet.
Maybe it'll help someone :)
moljac commentedon Jun 1, 2023
@Lsdenis
Thanks for the feedback.
Yes it is about transitive dependencies and what gets referenced + google moving types around.
It works on few other samples I am investigating. Still several to do.
It did. Thanks
moljac commentedon Jun 1, 2023
As temp workaround try explicitly adding following PackageReferences:
and yes - please report here if workaround works.
tklempay commentedon Jun 8, 2023
In the process of porting a Xamarin native app (android and ios) to .NET MAUI. In the port of android, fixed all of the compilation errors only to hit this bug. Adding your explicit package references cleared up the error. Thanks!
moljac commentedon Jun 11, 2023
@tklempay Thanks for the feedback!
moljac commentedon Jul 9, 2023
Duplicates:
#717
#742
#747
#749