Skip to content
This repository has been archived by the owner on Nov 6, 2024. It is now read-only.

[Regression] Xamarin.Firebase.Analytics 121.2.2 - Type androidx.lifecycle.DispatchQueue is defined multiple times #775

Closed
mateusz-waldman opened this issue May 16, 2023 · 11 comments

Comments

@mateusz-waldman
Copy link

mateusz-waldman commented May 16, 2023

Steps to reproduce:

  1. Create a new (default) MAUI project (Visual Studio 17.6)
  2. Add latest stable Xamarin.Firebase.Analytics

Xamarin.Firebase.Analytics 121.2.0.1 works
Xamarin.Firebase.Analytics 121.2.2 does NOT work

1>MSBUILD : java.exe error JAVA0000: Error in C:\Users\...\.nuget\packages\xamarin.androidx.lifecycle.common\2.6.1.1\buildTransitive\net6.0-android31.0\..\..\jar\androidx.lifecycle.lifecycle-common.jar:androidx/lifecycle/DispatchQueue.class:
1>MSBUILD : java.exe error JAVA0000: Type androidx.lifecycle.DispatchQueue is defined multiple times: C:\Users\...\.nuget\packages\xamarin.androidx.lifecycle.common\2.6.1.1\buildTransitive\net6.0-android31.0\..\..\jar\androidx.lifecycle.lifecycle-common.jar:androidx/lifecycle/DispatchQueue.class, obj\Debug\net7.0-android\lp\154\jl\classes.jar:androidx/lifecycle/DispatchQueue.class
1>MSBUILD : java.exe error JAVA0000: Compilation failed
1>MSBUILD : java.exe error JAVA0000: java.lang.RuntimeException: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: C:\Users\...\.nuget\packages\xamarin.androidx.lifecycle.common\2.6.1.1\buildTransitive\net6.0-android31.0\..\..\jar\androidx.lifecycle.lifecycle-common.jar
1>MSBUILD : java.exe error JAVA0000: androidx/lifecycle/DispatchQueue.class

Installed Workload Id Manifest Version Installation Source
maui-windows 7.0.86/7.0.100 VS 17.6.33712.159
maui-maccatalyst 7.0.86/7.0.100 VS 17.6.33712.159
maui-ios 7.0.86/7.0.100 VS 17.6.33712.159
maui-android 7.0.86/7.0.100 VS 17.6.33712.159
android 33.0.46/7.0.100 VS 17.6.33712.159
maccatalyst 16.4.7054/7.0.100 VS 17.6.33712.159
ios 16.4.7054/7.0.100 VS 17.6.33712.159

@AlexNik4
Copy link

I am getting the same error with new .NET 7 Android project that has:

<PackageReference Include="ReactiveUI.AndroidX" Version="18.4.44" />
<PackageReference Include="Xamarin.GooglePlayServices.Code.Scanner" Version="116.0.0" />

Simple repro project here: https://github.com/AlexNik4/barcode-scan-java0000

@moljac
Copy link
Member

moljac commented May 24, 2023

Duplicate

dotnet/android-libraries#717

@jonpryor
Copy link
Member

Possible workaround?

you'll have to manually add the newest Lifecycle nugets, since nuget always chooses the lowest transitive dependency that it can

@AlexNik4
Copy link

@jonpryor I tried adding the Xamarin.AndroidX.Lifecycle.Common package manually. None of the versions worked:
Using Xamarin.AndroidX.Lifecycle.Common 2.6.1 or lower:
Error NU1605 Warning As Error: Detected package downgrade: Xamarin.AndroidX.Lifecycle.Common from 2.6.1.1 to 2.6.1.

Using 2.6.1.1 I get the same error as without the manual reference:
Error JAVA0000 Error in C:\Users\Alex\.nuget\packages\xamarin.androidx.lifecycle.common\2.6.1.1\buildTransitive\net6.0-android31.0\..\..\jar\androidx.lifecycle.lifecycle-common.jar:androidx/lifecycle/DispatchQueue.class:

Using 2.6.1.2 (latest version):
Error JAVA0000 Error in C:\Users\Alex\.nuget\packages\xamarin.androidx.lifecycle.common\2.6.1.2\buildTransitive\net6.0-android31.0\..\..\jar\androidx.lifecycle.lifecycle-common.jar:androidx/lifecycle/LifecycleController.class:

Nothing in the full error references any other lifecycle packages.

@moljac
Copy link
Member

moljac commented Jun 1, 2023

As temp workaround try explicitly adding following PackageReferences:

		<PackageReference Include="Xamarin.AndroidX.Activity" Version="1.7.2" />
		<PackageReference Include="Xamarin.AndroidX.Activity.Ktx" Version="1.7.2" />

and yes - please report here if workaround works.

@AlexNik4
Copy link

AlexNik4 commented Jun 1, 2023

Yes! That worked. In fact adding just:
<PackageReference Include="Xamarin.AndroidX.Activity.Ktx" Version="1.7.2" />
was enough to build and use the new code scan package.

But there are exactly 100 JAVAC warnings as well. Hope these can be cleaned up in the future:
image

@IgorSava
Copy link

IgorSava commented Jun 2, 2023

As temp workaround try explicitly adding following PackageReferences:

		<PackageReference Include="Xamarin.AndroidX.Activity" Version="1.7.2" />
		<PackageReference Include="Xamarin.AndroidX.Activity.Ktx" Version="1.7.2" />

and yes - please report here if workaround works.

it`s works !

@moljac
Copy link
Member

moljac commented Jun 8, 2023

But there are exactly 100 JAVAC warnings as well. Hope these can be cleaned up in the future

This was fixed. Google moves code around and that was the reason for those warnings. Try using Xamarin.AndroidX.Annotation:1.6.0.3. That should help

@moljac
Copy link
Member

moljac commented Jun 8, 2023

Closing this issue

@moljac moljac closed this as completed Jun 8, 2023
@get-flat
Copy link

@moljac thank you for the workarounds.

Could you please provide additional information what to expect next?

  1. issue was closed and the final solution (not a workaround) is to always reference Xamarin.AndroidX.Activity.Ktx whenever someone wants to use Xamarin.Firebase.Analytics
  2. issue was closed because of the temporary workaround is available - how would the proper fix be communicated (when explicitly referencing Xamarin.AndroidX.Activity.Ktx will no longer be required)

@moljac
Copy link
Member

moljac commented Jun 19, 2023

@moljac thank you for the workarounds.

You are welcome.

Could you please provide additional information what to expect next?

  1. issue was closed and the final solution (not a workaround) is to always reference Xamarin.AndroidX.Activity.Ktx whenever someone wants to use Xamarin.Firebase.Analytics

In general, no. We took some measures that will render that as unnecessary. The problem is that google moves types from artifact to artifact and if your real world app setup (nuget dependencies) cause that transitive dependencies reference 2 nugets/assemblies where some type appear, this error might happen. Especially with 3rd party libraries/packages/plugins which reference older packages and that is not within our control.

  1. issue was closed because of the temporary workaround is available - how would the proper fix be communicated (when explicitly referencing Xamarin.AndroidX.Activity.Ktx will no longer be required)

Simply: update to latest and be vocal that 3rd party libraries are updated.

In the future I will do "alignment bumps" to ensure that published packages use always the latest, but that is for 500+ packages we maintain. If someone uses older version this error might happen again.

Another reason I closed this issue - it is easier to detect if the issue is with our nuget or some 3rd party.

Just this issue:

<PackageReference Include="ReactiveUI.AndroidX" Version="18.4.44" />
<PackageReference Include="Xamarin.GooglePlayServices.Code.Scanner" Version="116.0.0" />

GPS-FB-MLKit was aligned week or so ago.

OP's dependecy:

Xamarin.Firebase.Analytics

because it was prior to "alignment bump"

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

No branches or pull requests

6 participants