Essentials icon indicating copy to clipboard operation
Essentials copied to clipboard

Xamarin.Essentials.Browser.OpenAsync on Samsung Galaxy M31

Open vsfeedback opened this issue 3 years ago • 9 comments

This issue has been moved from a ticket on Developer Community.


[severity:It bothers me. A fix would be nice] This is PRODUCTION issue. Line code: Browser.OpenAsync(url, BrowserLaunchMode.External); First happen after adding "await ", did not use it with async until now (don't now if related, just mentioning) Recently Xamarin.Essentials 1.70 Xamarin.Forms 5.0.0.2196

android.runtime.JavaProxyThrowable:
 at Xamarin.Essentials.Browser.PlatformOpenAsync (System.Uri uri, Xamarin.Essentials.BrowserLaunchOptions options) \[0x00164\] in :0
 at Xamarin.Essentials.Browser.OpenAsync (System.Uri uri, Xamarin.Essentials.BrowserLaunchOptions options) \[0x00006\] in :0
 at Xamarin.Essentials.Browser.OpenAsync (System.String uri, Xamarin.Essentials.BrowserLaunchOptions options) \[0x0001e\] in :0
 at Xamarin.Essentials.Browser.OpenAsync (System.String uri, Xamarin.Essentials.BrowserLaunchMode launchMode) \[0x0000d\] in :0
 at MyApp.StartPage.OpenUrl (System.String url) \[0x0000a\] in :0
 at MyApp.StartPage.LinksMenuClicked (System.Object sender, System.EventArgs e) \[0x001d9\] in :0
 at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.b\_\_7\_0 (System.Object state) \[0x00000\] in :0
 at Android.App.SyncContext+<>c\_\_DisplayClass2\_0.b\_\_0 () \[0x00000\] in :0
 at Java.Lang.Thread+RunnableImplementor.Run () \[0x00008\] in :0
 at Java.Lang.IRunnableInvoker.n\_Run (System.IntPtr jnienv, System.IntPtr native\_\_this) \[0x00008\] in :0
 at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.41(intptr,intptr)
 at mono.java.lang.RunnableImplementor.n\_run (Native Method)
 at mono.java.lang.RunnableImplementor.run (RunnableImplementor.java:30)
 at android.os.Handler.handleCallback (Handler.java:938)
 at android.os.Handler.dispatchMessage (Handler.java:99)
 at android.os.Looper.loop (Looper.java:246)
 at android.app.ActivityThread.main (ActivityThread.java:8595)
 at java.lang.reflect.Method.invoke (Native Method)
 at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:602)
 at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1130)

Original Comments

Feedback Bot on 10/21/2021, 06:17 PM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.


Original Solutions

Tomer Zilka solved on 10/24/2021, 05:22 AM, 0 votes:

[Workaround]
Update:
Android 11 throws when using BrowserLaunchMode.External:
await Browser.OpenAsync(url, BrowserLaunchMode.External);
“Xamarin.Essentials.FeatureNotSupportedException: ‘Specified method is not supported.’”

When using BrowserLaunchMode.SystemPreferred it works sleek.

vsfeedback avatar Oct 28 '21 20:10 vsfeedback

The issue is not related to the device, I have the same issue on Oppo phone with Android 11 and BrowserLaunchMode.External.

leonardbarbu avatar Nov 22 '21 10:11 leonardbarbu

Also happening on Samsung Galaxy M11 Android 11

gianisimone avatar Dec 20 '21 11:12 gianisimone

I have same problem on Nokia 5.3 Android 11 with BrowserLaunchMode.External when I changed it to BrowserLaunchMode.SystemPreferred it works.

pinkysek avatar Jan 18 '22 10:01 pinkysek

Solution for this issue is here. If your project target Android version is set to Android 11 (R API 30) you must update your Android Manifest.

Add the following inside of the manifest node:

<queries>
  <intent>
    <action android:name="android.intent.action.VIEW" />
    <data android:scheme="http"/>
  </intent>
  <intent>
    <action android:name="android.intent.action.VIEW" />
    <data android:scheme="https"/>
  </intent>
</queries>

pinkysek avatar Jan 18 '22 12:01 pinkysek

Solution for this issue is here. If your project target Android version is set to Android 11 (R API 30) you must update your Android Manifest.

Add the following inside of the manifest node: <queries> <intent> <action android:name="android.intent.action.VIEW" /> <data android:scheme="http"/> </intent> <intent> <action android:name="android.intent.action.VIEW" /> <data android:scheme="https"/> </intent> </queries>

I have includes these queries, and even with this specified, i got this error on several Galaxy devices, LG K9, Xperia L3 running on Android 10 and 11

rkops-bd avatar Jan 27 '22 07:01 rkops-bd

What is the url scheme? http/https? or is it a custom uri?

mattleibow avatar Jan 28 '22 19:01 mattleibow

BrowserLaunchMode.External does not work on android device with android 11+ It crashes with FeatureNotSupportedException Tested on multiple devices.

softlion avatar Mar 18 '22 10:03 softlion

Is that more related to the new "query" attribute required for app targeting api 30 ?

https://medium.com/androiddevelopers/package-visibility-in-android-11-cc857f221cd9

Duplicate of #1958 ?

softlion avatar Mar 18 '22 11:03 softlion

Solution for this issue is here. If your project target Android version is set to Android 11 (R API 30) you must update your Android Manifest.

Add the following inside of the manifest node:

<queries>
  <intent>
    <action android:name="android.intent.action.VIEW" />
    <data android:scheme="http"/>
  </intent>
  <intent>
    <action android:name="android.intent.action.VIEW" />
    <data android:scheme="https"/>
  </intent>
</queries>

After adding this code and then doing a Clean & Compile on all projects works perfect!

Luisalvarenga avatar May 05 '22 05:05 Luisalvarenga