ionic-team / capacitor-plugins

Official plugins for Capacitor ⚑️

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

bug(@capacitor/browser): Urls without https cause browser.open to crashes application

emelampianakis opened this issue Β· comments

Bug Report

Plugin(s)

@capacitor/browser ^5.2.0

Capacitor Version

πŸ’Š   Capacitor Doctor  πŸ’Š

Latest Dependencies:

  @capacitor/cli: 5.7.0
  @capacitor/core: 5.7.0
  @capacitor/android: 5.7.0
  @capacitor/ios: 5.7.0

Installed Dependencies:

  @capacitor/cli: 5.7.0
  @capacitor/ios: 5.7.0
  @capacitor/core: 5.7.0
  @capacitor/android: 5.7.0

[success] iOS looking great! πŸ‘Œ
[success] Android looking great! πŸ‘Œ

Platform(s)

Android

Current Behavior

This happens when the app is opened from the push listener 'notificationActionPerformed'
In the notification data: urlToOpen = 'www.google.com'
When using .open({url: urlToOpen}) app crashes & stays unresponsive until app data are cleared

If the urlToOpen = 'https://www.google.com/' --> works as expected.

Expected Behavior

Open the url in the in app browser

Code Reproduction

 FirebaseMessaging.addListener('notificationActionPerformed', async (event) => {
        const urlToOpen = event.notification.data.urlToOpen;
        await Browser.open({
          url: urlToOpen,
        });
      });

Other Technical Details

Additional Context

The crashlytics report:

Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myapp/com.capacitorjs.plugins.browser.BrowserControllerActivity}: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat= pkg=com.android.chrome (has extras) }
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3897)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4043)
       at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:101)
       at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
       at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2437)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loopOnce(Looper.java:211)
       at android.os.Looper.loop(Looper.java:300)
       at android.app.ActivityThread.main(ActivityThread.java:8294)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1028)

Caused by android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat= pkg=com.android.chrome (has extras) }
       at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:2220)
       at android.app.Instrumentation.execStartActivity(Instrumentation.java:1859)
       at android.app.Activity.startActivityForResult(Activity.java:5624)
       at androidx.activity.ComponentActivity.startActivityForResult(ComponentActivity.java:753)
       at android.app.Activity.startActivityForResult(Activity.java:5577)
       at androidx.activity.ComponentActivity.startActivityForResult(ComponentActivity.java:734)
       at android.app.Activity.startActivity(Activity.java:6095)
       at androidx.core.content.ContextCompat$Api16Impl.startActivity(ContextCompat.java:978)
       at androidx.core.content.ContextCompat.startActivity(ContextCompat.java:318)
       at androidx.browser.customtabs.CustomTabsIntent.launchUrl(CustomTabsIntent.java:483)
       at com.capacitorjs.plugins.browser.Browser.open(Browser.java:112)
       at com.capacitorjs.plugins.browser.BrowserControllerActivity.open(BrowserControllerActivity.java:43)
       at com.capacitorjs.plugins.browser.BrowserPlugin.lambda$open$0(BrowserPlugin.java:72)
       at com.capacitorjs.plugins.browser.BrowserPlugin.$r8$lambda$I9bLDRWh7vl57kOTAfjVKp5lWOU()
       at com.capacitorjs.plugins.browser.BrowserPlugin$$ExternalSyntheticLambda0.onControllerReady(:8)
       at com.capacitorjs.plugins.browser.BrowserControllerActivity.onCreate(BrowserControllerActivity.java:19)
       at android.app.Activity.performCreate(Activity.java:8538)
       at android.app.Activity.performCreate(Activity.java:8502)
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1437)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3878)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4043)
       at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:101)
       at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
       at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2437)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loopOnce(Looper.java:211)
       at android.os.Looper.loop(Looper.java:300)
       at android.app.ActivityThread.main(ActivityThread.java:8294)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1028)

This issue has been labeled as type: bug. This label is added to issues that that have been reproduced and are being tracked in our internal issue tracker.

Updating the issue to reflect that this issue is about catching the error thrown off from not having a valid URL

i have same crash log like

Fatal Exception: java.lang.RuntimeException
Unable to start activity ComponentInfo{com.app.example/com.capacitorjs.plugins.browser.BrowserControllerActivity}: android.content.ActivityNotFoundException: 

No Activity found to handle Intent { act=android.intent.action.VIEW dat=blob:https://com.app.example/3781e39f-7d87-4e85-b041-a8e20a4e9602 pkg=com.android.chrome (has extras) }