-
Notifications
You must be signed in to change notification settings - Fork 80
Description
Description
The Android app crashes with an unhandled ActivityNotFoundException when attempting to authenticate on a device that doesn't have Chrome or any compatible custom chrome tabs browser installed.
Proposed fix:
try {
if (callbackScheme == "https" && callbackHost != null && callbackPath != null) {
intent.launch(this, authLauncher, authenticationUri, callbackHost!!, callbackPath!!)
} else {
intent.launch(this, authLauncher, authenticationUri, callbackScheme)
}
authStarted = true
} catch (e: android.content.ActivityNotFoundException) {
Log.e(LOG_TAG, "ActivityNotFoundException: No browser available", e)
val callback = FlutterWebAuth2Plugin.callbacks[callbackScheme]
callback?.error("NO_BROWSER", "No browser available on this device.", e.message)
FlutterWebAuth2Plugin.callbacks.remove(callbackScheme)
finish()
}Minimal Reproduction
Steps to reproduce the behaviour:
Run the app on an Android device/emulator without Chrome or any browser installed
Trigger authentication using FlutterWebAuth2.authenticate()
App crashes immediately
- Use the following code:
<Paste your code here>
- [...]
Exception or Error
E/AndroidRuntime: FATAL EXCEPTION: main
E/AndroidRuntime: Caused by: android.content.ActivityNotFoundException:
No Activity found to handle Intent { act=android.intent.action.VIEW ... pkg=com.android.chrome }
Expected Behaviour
The error should be caught and returned to Flutter as a PlatformException, allowing the app to handle it gracefully (e.g., show an error message to the user).
Screenshots
No response
Additional context
No response
Device
Samsung S22 Ultra
OS
Android 16
Browser
Opera (only opera available on the device)
Flutter version
3.32.8
flutter_web_auth_2 version
5.0.0-alpha.7
Checklist
- I have read and followed the entire troubleshooting guide and it has not provided the solution I need.
- I have provided all the information I can.