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

Maui 7 Setup push notification Xamarin.GooglePlayServices.Base compilation Failed #788

Closed
developer9969 opened this issue Sep 16, 2023 · 6 comments
Labels
duplicate This issue or pull request already exists needs-info

Comments

@developer9969
Copy link

Android application type

.NET Android (net7.0-android, etc.)

Affected platform version

VS 2022 any version

Description

I am trying to set up push notification on Maui using .net 7 - Cannot move to .net 8 because of other Maui issues
as soon as I add Xamarin.GooglePlayServices.Base the app no longer builds

What nuget packages do i need to use to enable push notification with firebase?

Steps to Reproduce

  1. Added google-services.json to solution
  2. Added Xamarin.GooglePlayServices.Base 118.2.0.2 so that I could set the google-services.json build action accordingly
  3. Built solution - get compilation failure

Did you find any workaround?

Nope

Relevant log output

Severity	Code	Description	Project	File	Line	Suppression State
Error	JAVA0000	Picked up _JAVA_OPTIONS: -Xmx512M
Error in C:\Users\theuser\.nuget\packages\xamarin.androidx.lifecycle.common\2.6.1.2\buildTransitive\net6.0-android31.0\..\..\jar\androidx.lifecycle.lifecycle-common.jar:androidx/lifecycle/DispatchQueue.class:
Type androidx.lifecycle.DispatchQueue is defined multiple times: C:\Users\theuser\.nuget\packages\xamarin.androidx.lifecycle.common\2.6.1.2\buildTransitive\net6.0-android31.0\..\..\jar\androidx.lifecycle.lifecycle-common.jar:androidx/lifecycle/DispatchQueue.class, obj\Debug\net7.0-android\lp\167\jl\classes.jar:androidx/lifecycle/DispatchQueue.class
Compilation failed
java.lang.RuntimeException: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: C:\Users\theuser\.nuget\packages\xamarin.androidx.lifecycle.common\2.6.1.2\buildTransitive\net6.0-android31.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: C:\Users\theuser\.nuget\packages\xamarin.androidx.lifecycle.common\2.6.1.2\buildTransitive\net6.0-android31.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: C:\Users\theuser\.nuget\packages\xamarin.androidx.lifecycle.common\2.6.1.2\buildTransitive\net6.0-android31.0\..\..\jar\androidx.lifecycle.lifecycle-common.jar:androidx/lifecycle/DispatchQueue.class, obj\Debug\net7.0-android\lp\167\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
@jpobst jpobst transferred this issue from dotnet/android Sep 16, 2023
@jpobst jpobst removed their assignment Sep 16, 2023
@jpobst
Copy link
Contributor

jpobst commented Sep 16, 2023

See #764 for information and fix.

@developer9969
Copy link
Author

developer9969 commented Sep 17, 2023

@jpobst thanks for the link - read it a few times but still cannot make it work!. Now iOS is not happy and prevent from compiling.. I get that each person can have a different issue but surely someone could have created a doc of what references are required in order to set up push notification.
Any suggestions?

I have tried adding as follows:

  1. Deleted bin - obj
  2. Added below references

<PackageReference Include="Xamarin.AndroidX.Activity.Ktx" Version="1.7.2.1" /> <PackageReference Include="Xamarin.Firebase.Messaging"> <Version>123.1.1.1</Version> </PackageReference> <PackageReference Include="Xamarin.Google.Dagger"> <Version>2.44.2.1</Version> </PackageReference> <PackageReference Include="Xamarin.GooglePlayServices.Base"> <Version>118.1.0.1</Version> </PackageReference>

  1. Getting Severity Code Description Project File Line Suppression State
    Error NU1202 Package Xamarin.GooglePlayServices.Base 118.2.0.2 is not compatible with net7.0-ios16.1 (.NETCoreApp,Version=v7.0). Package Xamarin.GooglePlayServices.Base 118.2.0.2 supports:
  • monoandroid12.0 (MonoAndroid,Version=v12.0)
  • net6.0-android31.0 (.NETCoreApp,Version=v6.0)

image

@moljac
Copy link
Contributor

moljac commented Sep 18, 2023

@developer9969

try adding Condition attribute

Something like this:

  <ItemGroup Condition="$(TargetFramework.Contains('-android'))">
	<PackageReference Include="Xamarin.AndroidX.Activity.Ktx" Version="1.7.2.1" /> 
  	<PackageReference Include="Xamarin.Firebase.Messaging"> 
		<Version>123.1.1.1</Version> 
	</PackageReference> 
	<PackageReference Include="Xamarin.Google.Dagger"> 
		<Version>2.44.2.1</Version> 
	</PackageReference> 
	<PackageReference Include="Xamarin.GooglePlayServices.Base"> 
		<Version>118.1.0.1</Version> 
	</PackageReference>  
  </ItemGroup>

@moljac
Copy link
Contributor

moljac commented Oct 16, 2023

@developer9969

Did my tip help? Thanks

@moljac moljac added duplicate This issue or pull request already exists needs-info labels Oct 16, 2023
@developer9969
Copy link
Author

@moljac that did help and sorted the problem thank you -

@jeff-eats-pubsubs
Copy link

jeff-eats-pubsubs commented Jul 23, 2024

Any success/wisdom @developer9969 @moljac on updating these packages successfully?

This is exactly the same setup that I am using.

This works great!

	<ItemGroup Condition="'$(TargetFramework)' == 'net8.0-android'">
		<PackageReference Include="Xamarin.AndroidX.Activity.Ktx" Version="1.7.2.1" />
		<PackageReference Include="Xamarin.Firebase.Messaging" Version="123.1.1.1"/>
		<PackageReference Include="Xamarin.Google.Dagger" Version="2.44.2.1"/>
		<PackageReference Include="Xamarin.GooglePlayServices.Base" Version="118.1.0.1"/>
	</ItemGroup>

This fails to build.

	<ItemGroup Condition="'$(TargetFramework)' == 'net8.0-android'">
		<PackageReference Include="Xamarin.AndroidX.Activity.Ktx" Version="1.9.0.4" />
		<PackageReference Include="Xamarin.Firebase.Messaging" Version="124.0.0" />
		<PackageReference Include="Xamarin.Google.Dagger" Version="2.51.1" />
		<PackageReference Include="Xamarin.GooglePlayServices.Base" Version="118.5.0" />
	</ItemGroup>

with

1>MSBUILD : java.exe error JAVA0000: Error in obj\Release\net8.0-android\lp\145\jl\classes.jar:androidx/lifecycle/LiveDataKt$observe$wrappedObserver$1.class:
1>MSBUILD : java.exe error JAVA0000: Type androidx.lifecycle.LiveDataKt$observe$wrappedObserver$1 is defined multiple times: obj\Release\net8.0-android\lp\145\jl\classes.jar:androidx/lifecycle/LiveDataKt$observe$wrappedObserver$1.class, obj\Release\net8.0-android\lp\185\jl\classes.jar:androidx/lifecycle/LiveDataKt$observe$wrappedObserver$1.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: obj\Release\net8.0-android\lp\145\jl\classes.jar
1>MSBUILD : java.exe error JAVA0000: androidx/lifecycle/LiveDataKt$observe$wrappedObserver$1.class
1>MSBUILD : java.exe error JAVA0000: 	at com.android.tools.r8.utils.S0.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:135)
1>MSBUILD : java.exe error JAVA0000: 	at com.android.tools.r8.D8.main(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:5)
1>MSBUILD : java.exe error JAVA0000: Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: obj\Release\net8.0-android\lp\145\jl\classes.jar:androidx/lifecycle/LiveDataKt$observe$wrappedObserver$1.class
1>MSBUILD : java.exe error JAVA0000: 	at Version.fakeStackEntry(Version_8.2.33.java:0)
1>MSBUILD : java.exe error JAVA0000: 	at com.android.tools.r8.T.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:5)
1>MSBUILD : java.exe error JAVA0000: 	at com.android.tools.r8.utils.S0.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:82)
1>MSBUILD : java.exe error JAVA0000: 	at com.android.tools.r8.utils.S0.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:32)
1>MSBUILD : java.exe error JAVA0000: 	at com.android.tools.r8.utils.S0.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:31)
1>MSBUILD : java.exe error JAVA0000: 	at com.android.tools.r8.utils.S0.b(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:2)
1>MSBUILD : java.exe error JAVA0000: 	at com.android.tools.r8.D8.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:42)
1>MSBUILD : java.exe error JAVA0000: 	at com.android.tools.r8.D8.b(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:13)
1>MSBUILD : java.exe error JAVA0000: 	at com.android.tools.r8.D8.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:40)
1>MSBUILD : java.exe error JAVA0000: 	at com.android.tools.r8.utils.S0.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:122)
1>MSBUILD : java.exe error JAVA0000: 	... 1 more
1>MSBUILD : java.exe error JAVA0000: Caused by: com.android.tools.r8.utils.b: Type androidx.lifecycle.LiveDataKt$observe$wrappedObserver$1 is defined multiple times: obj\Release\net8.0-android\lp\145\jl\classes.jar:androidx/lifecycle/LiveDataKt$observe$wrappedObserver$1.class, obj\Release\net8.0-android\lp\185\jl\classes.jar:androidx/lifecycle/LiveDataKt$observe$wrappedObserver$1.class
1>MSBUILD : java.exe error JAVA0000: 	at com.android.tools.r8.utils.Q2.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:21)
1>MSBUILD : java.exe error JAVA0000: 	at com.android.tools.r8.utils.D2.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:54)
1>MSBUILD : java.exe error JAVA0000: 	at com.android.tools.r8.utils.D2.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:10)
1>MSBUILD : java.exe error JAVA0000: 	at java.base/java.util.concurrent.ConcurrentHashMap.merge(ConcurrentHashMap.java:2056)
1>MSBUILD : java.exe error JAVA0000: 	at com.android.tools.r8.utils.D2.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:6)
1>MSBUILD : java.exe error JAVA0000: 	at com.android.tools.r8.graph.m4$a.d(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:6)
1>MSBUILD : java.exe error JAVA0000: 	at com.android.tools.r8.dex.c.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:61)
1>MSBUILD : java.exe error JAVA0000: 	at com.android.tools.r8.dex.c.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:12)
1>MSBUILD : java.exe error JAVA0000: 	at com.android.tools.r8.dex.c.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:9)
1>MSBUILD : java.exe error JAVA0000: 	at com.android.tools.r8.D8.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:45)
1>MSBUILD : java.exe error JAVA0000: 	at com.android.tools.r8.D8.d(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:17)
1>MSBUILD : java.exe error JAVA0000: 	at com.android.tools.r8.D8.c(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:69)
1>MSBUILD : java.exe error JAVA0000: 	at com.android.tools.r8.utils.S0.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:28)
1>MSBUILD : java.exe error JAVA0000: 	... 6 more
1>MSBUILD : java.exe error JAVA0000: Directory 'obj\Release\net8.0-android\lp\145' is from 'androidx.lifecycle.lifecycle-livedata-core.aar'.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists needs-info
Projects
None yet
Development

No branches or pull requests

4 participants