Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding references to Xamarin.GooglePlayServices.Base 118,2.0.4 prevents building the app #8490

Closed
gabsamples6 opened this issue Nov 8, 2023 · 5 comments
Assignees
Labels
Area: Bindings Issues in Java Library Binding projects. need-attention A xamarin-android contributor needs to review

Comments

@gabsamples6
Copy link

gabsamples6 commented Nov 8, 2023

Android application type

.Maui app using .net 8
image

Affected platform version

Version 17.8.0 Preview 7

Description

I am trying to build an app that uses push Notification and we need to upgrade our nuget to use the latest Xamarin.Firebase.Messaging

However this requires a version of Xamarin.GooglePlayServices.Base that causes an issue when added to the project
image

Severity Code Description Project File Line Suppression State
Error JAVA0000 Error in C:\Nuget\xamarin.androidx.collection.jvm\1.3.0.1\buildTransitive\net6.0-android31.0....\jar\androidx.collection.collection-jvm.jar:androidx/collection/ArrayMapKt.class:
Type androidx.collection.ArrayMapKt is defined multiple times:
C:\Nuget\xamarin.androidx.collection.jvm\1.3.0.1\buildTransitive\net6.0-android31.0....\jar\androidx.collection.collection-jvm.jar:androidx/collection/ArrayMapKt.class, C:\Nuget\xamarin.androidx.collection.ktx\1.2.0.9\buildTransitive\net6.0-android31.0....\jar\androidx.collection.collection-ktx.jar:androidx/collection/ArrayMapKt.class
Compilation failed
java.lang.RuntimeException: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: C:\Nuget\xamarin.androidx.collection.jvm\1.3.0.1\buildTransitive\net6.0-android31.0....\jar\androidx.collection.collection-jvm.jar
androidx/collection/ArrayMapKt.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: C:\Nuget\xamarin.androidx.collection.jvm\1.3.0.1\buildTransitive\net6.0-android31.0....\jar\androidx.collection.collection-jvm.jar:androidx/collection/ArrayMapKt.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.ArrayMapKt is defined multiple times: C:\Nuget\xamarin.androidx.collection.jvm\1.3.0.1\buildTransitive\net6.0-android31.0....\jar\androidx.collection.collection-jvm.jar:androidx/collection/ArrayMapKt.class, C:\Nuget\xamarin.androidx.collection.ktx\1.2.0.9\buildTransitive\net6.0-android31.0....\jar\androidx.collection.collection-ktx.jar:androidx/collection/ArrayMapKt.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)

Steps to Reproduce

  1. Create a maui app
  2. Add Xamarin.Firebase.Messaging 123.2.11
  3. Add Xamarin.GooglePlayServices.Base 118.2.0.4

and we get the issue

Any suggestions?

Did you find any workaround?

no

Relevant log output

Severity	Code	Description	Project	File	Line	Suppression State
Error	JAVA0000	Error in C:\Nuget\xamarin.androidx.collection.jvm\1.3.0.1\buildTransitive\net6.0-android31.0\..\..\jar\androidx.collection.collection-jvm.jar:androidx/collection/ArrayMapKt.class:
Type androidx.collection.ArrayMapKt is defined multiple times: C:\Nuget\xamarin.androidx.collection.jvm\1.3.0.1\buildTransitive\net6.0-android31.0\..\..\jar\androidx.collection.collection-jvm.jar:androidx/collection/ArrayMapKt.class, C:\Nuget\xamarin.androidx.collection.ktx\1.2.0.9\buildTransitive\net6.0-android31.0\..\..\jar\androidx.collection.collection-ktx.jar:androidx/collection/ArrayMapKt.class
Compilation failed
java.lang.RuntimeException: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: C:\Nuget\xamarin.androidx.collection.jvm\1.3.0.1\buildTransitive\net6.0-android31.0\..\..\jar\androidx.collection.collection-jvm.jar
androidx/collection/ArrayMapKt.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: C:\Nuget\xamarin.androidx.collection.jvm\1.3.0.1\buildTransitive\net6.0-android31.0\..\..\jar\androidx.collection.collection-jvm.jar:androidx/collection/ArrayMapKt.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.ArrayMapKt is defined multiple times: C:\Nuget\xamarin.androidx.collection.jvm\1.3.0.1\buildTransitive\net6.0-android31.0\..\..\jar\androidx.collection.collection-jvm.jar:androidx/collection/ArrayMapKt.class, C:\Nuget\xamarin.androidx.collection.ktx\1.2.0.9\buildTransitive\net6.0-android31.0\..\..\jar\androidx.collection.collection-ktx.jar:androidx/collection/ArrayMapKt.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)
		1
@gabsamples6 gabsamples6 added Area: App+Library Build Issues when building Library projects or Application projects. needs-triage Issues that need to be assigned. labels Nov 8, 2023
@dellis1972 dellis1972 added Area: Bindings Issues in Java Library Binding projects. and removed Area: App+Library Build Issues when building Library projects or Application projects. needs-triage Issues that need to be assigned. labels Nov 8, 2023
@moljac
Copy link
Contributor

moljac commented Nov 8, 2023

Hi @gabsamples6

Thanks for the feedback. This is GooglePlayServices/Firebase related issue and due to the fact that those depend on AndroidX the issue has been filed in AndroidX repo already.

xamarin/AndroidX#797 (comment)

Issue reported in MAUI repo:

dotnet/maui#18118 (comment)

Adding following snippet should help (I could bet this would be the solution in your case):

<PackageReference Include="Xamarin.AndroidX.Collection" Version="1.3.0.1" />
<PackageReference Include="Xamarin.AndroidX.Collection.Ktx" Version="1.3.0.1" />

Some users reported adding this helped:

   <ItemGroup>
    <PackageReference Include="Xamarin.AndroidX.Preference" Version="1.2.1.2" />
    <PackageReference Include="Xamarin.Google.Android.Material" Version="1.10.0.1" />
  </ItemGroup>

It depends on forest (graph) of transitive dependencies and for real world project it is not trivial (3rd party packages like plugins might pull in centuries old nugets that cause such issues).

If that does not help - general rule is:

  1. to update to latest packages (all)

  2. if no. 1 does not help - explicitly add latest version of some dependency packages.
    sometimes needs some experimenting and digging.

  3. if no1. and no2. do not help - provide us your PackageReferences so we can do analysis. (needs-info)

OK. It is not rule but rules.

If that helps please report it here (ping me/mention me please) and close the issue yourself.

And suggestions to help us out to be more responsive:

  1. do not paste images. Instead paste/add relevant code from project - PackageDependency in this case is enough.
  2. search AX and GPS-FB-MLKit repos for related issues (those nugets are not tightly coupled to )

More info:

xamarin/AndroidX#764

@moljac moljac added the need-info Issues that need more information from the author. label Nov 8, 2023
@gabsamples6
Copy link
Author

Thanks for the prompt reply - let me see how I get on with your suggestions and read replies in those links

@microsoft-github-policy-service microsoft-github-policy-service bot added need-attention A xamarin-android contributor needs to review and removed need-info Issues that need more information from the author. labels Nov 8, 2023
@jpobst
Copy link
Contributor

jpobst commented Nov 16, 2023

Due to inactivity, we will be closing this issue. Please feel free to re-open this issue if the issue persists. For enhanced visibility, if over 7 days have passed, please open a new issue and link this issue there. Thank you.

@jpobst jpobst closed this as completed Nov 16, 2023
@Quaybe
Copy link

Quaybe commented Dec 14, 2023

Adding following snippet should help (I could bet this would be the solution in your case):

<PackageReference Include="Xamarin.AndroidX.Collection" Version="1.3.0.1" />
<PackageReference Include="Xamarin.AndroidX.Collection.Ktx" Version="1.3.0.1" />

This resolved my issue. THANK YOU! I've been trying to use a barcode scanning package (BarcodeScanner.Mobile.Maui) that has a dependency on Xamarin.GooglePlayServices, preventing my app from building after adding the package.

For other noobs like myself, be sure to enclose these in an ItemGroup with a condition to only apply to Android like below, and fill in whatever .net version you're using currently. Current version of these packages as of this comment is 1.3.0.2:

  <ItemGroup Condition="(  '$(TargetFramework)' == 'net8.0-android' )">
    <PackageReference Include="Xamarin.Google.MLKit.BarcodeScanning" Version="117.2.0.2" />
    <PackageReference Include="Xamarin.AndroidX.Collection" Version="1.3.0.2" />
    <PackageReference Include="Xamarin.AndroidX.Collection.Ktx" Version="1.3.0.2" />
  </ItemGroup>

Otherwise you will get errors stating it is not compatible with Windows, MacCatalyst, etc because they're only meant to be applied to Android.

@moljac
Copy link
Contributor

moljac commented Dec 14, 2023

For other noobs like myself, be sure to enclose these in an ItemGroup with a condition to only apply to Android like below, and fill in whatever .net version you're using currently. Current version of these packages as of this comment is 1.3.0.2:

yes. this is downside of multitargeting

@github-actions github-actions bot locked and limited conversation to collaborators Jan 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Area: Bindings Issues in Java Library Binding projects. need-attention A xamarin-android contributor needs to review
Projects
None yet
Development

No branches or pull requests

6 participants