Search code examples
flutterpluginsurl-launcher

Flutter url_launcher plugin throws "java.lang.IllegalArgumentException: Receiver not registered: io.flutter.plugins.urllauncher.WebViewActivity"


I'm attempting to use Flutter's url_launcher plugin to open webpages.

When I click a button url_launcher opens a webpage successfully. However, if I then navigate back by swiping left, or using the soft back button, the app crashes. The logs say

java.lang.RuntimeException: Unable to destroy activity {uk.co.pottertour.map_edinburgh_guide_airbnb/io.flutter.plugins.urllauncher.WebViewActivity}: java.lang.IllegalArgumentException: Receiver not registered: io.flutter.plugins.urllauncher.WebViewActivity$1@8152196

It says WebViewActivity so presumably Url_Launcher isn't opening an external browser but an in-app Webview.

This is pretty critical, this app is basically a hub for exciting things.

I was suspicious that my didChangeAppLifecycleState function was causing the error since it occurred on resume, but no, it's when Flutter runs build & rebuilds the screen.

I've tried commenting out parts of my build process that included url_launcher links, believing the rebuild triggered it, but this does not help. Perhaps there is some background asynchronous process, that throws this error before the app is painted to the screen. To do with url_launcher.


Solution

  • This is fixed in url_launched_android 6.0.34. The issue was tracked in https://github.com/flutter/flutter/issues/127014