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

Support MAUI, please #756

Closed
delahermosa opened this issue Jul 8, 2023 · 7 comments
Closed

Support MAUI, please #756

delahermosa opened this issue Jul 8, 2023 · 7 comments

Comments

@delahermosa
Copy link

Android application type

Not applicable

Affected platform version

VS 2022

Description

I cannot use the librarte in a MAUI project, will you support MAUI in the near future?

I have a project developed in Xamarin.Forms and It uses the class WebViewAssetsLoader, but this class is not available for MAUI.

Thanks in advance.

Relevant log output

No response

@jpobst
Copy link
Contributor

jpobst commented Jul 8, 2023

MAUI is fully supported.

Can you provide us more details?

  • What package(s) are you trying to use?
  • What error(s) do you get?

@moljac
Copy link
Contributor

moljac commented Jul 9, 2023

I cannot use the librarte in a MAUI project, will you support MAUI in the near future?

MAUI is supported. You need to try in Platform specific folder (Platforms/Android/) because WebViewAssetLoader is Android only API.

I have a project developed in Xamarin.Forms and It uses the class WebViewAssetsLoader, but this class is not available for MAUI.

WebViewAssetLoader

https://developer.android.com/reference/androidx/webkit/WebViewAssetLoader

is bound in WebKit nuget:

https://www.nuget.org/packages/Xamarin.AndroidX.WebKit

generated/androidx.webkit.webkit/obj/Release/net6.0-android/generated/src/AndroidX.WebKit.WebViewAssetLoader.cs
generated/androidx.webkit.webkit/obj/Release/monoandroid12.0/generated/src/AndroidX.WebKit.WebViewAssetLoader.cs

@delahermosa
Copy link
Author

delahermosa commented Jul 12, 2023

Hi!

When I add the nuget package Xamarin.AndroidX.WebKit to my MAUI project, the code looks good as far as VS identifies the class properly and intelisense works. But when I build the project, it fails throwing this error:

Gravedad	Código	Descripción	Proyecto	Archivo	Línea	Estado suprimido
Error	JAVA0000	Error in C:\Users\ut06931\.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\ut06931\.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-android33.0\lp\139\jl\classes.jar:androidx/lifecycle/DispatchQueue.class
Compilation failed
java.lang.RuntimeException: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: C:\Users\ut06931\.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\ut06931\.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\ut06931\.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-android33.0\lp\139\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\net7.0-android33.0\lp\139' is from 'androidx.lifecycle.lifecycle-runtime-ktx.aar'.	DemoWebView		1	

Thanks in advance!

@jpobst
Copy link
Contributor

jpobst commented Jul 13, 2023

Try adding this package to your project:

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

@moljac
Copy link
Contributor

moljac commented Jul 14, 2023

Related/Duplicates:

#752

#749

#747

#742

#717

#634

@rpharon
Copy link

rpharon commented Jul 18, 2023

Try adding this package to your project:

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

This got me the fix, after pasting the code:

  1. Quit VS Studio.
  2. Reopen VS Studio
  3. Clean, then Build Project.
  4. Android Emulator/Device should be working.

@delahermosa
Copy link
Author

Adding that reference made it work. Thanks!

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

No branches or pull requests

5 participants