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

android.content.ActivityNotFoundException: No Activity found to handle Intent #340

Closed
ar-g opened this issue Nov 2, 2020 · 12 comments · Fixed by #363
Closed

android.content.ActivityNotFoundException: No Activity found to handle Intent #340

ar-g opened this issue Nov 2, 2020 · 12 comments · Fixed by #363
Labels
needs investigation An issue that has more questions to answer or otherwise needs work to fully understand the issue

Comments

@ar-g
Copy link

ar-g commented Nov 2, 2020

We're getting quite a few exceptions on the Android side. I believe that the main cause is that we need to handle a case when the Browser app is not available on a specific Android device. So the solution would be to wrap this into the try-catch block and propagate the error to ReactNative and ask the user to download the Browser on the library consumer side. Another option is to check in advance if the browser is available https://developers.google.com/web/android/custom-tabs/implementation-guide#what_happens_if_the_user_doesn%E2%80%99t_have_a_browser_that_supports_custom_tabs_installed

Stacktrace:

* android.app.Instrumentation.checkStartActivityResult Instrumentation.java:2014

* android.app.Instrumentation.execStartActivity Instrumentation.java:1675

* android.app.Activity.startActivityForResult Activity.java:4601

* androidx.fragment.app.FragmentActivity.startActivityForResult FragmentActivity.java:6

* android.app.Activity.startActivityForResult Activity.java:4559

* androidx.fragment.app.FragmentActivity.startActivityForResult FragmentActivity.java:3

* android.app.Activity.startActivity Activity.java:4920

* androidx.core.content.ContextCompat.startActivity ContextCompat.java:2

* androidx.browser.customtabs.CustomTabsIntent.launchUrl CustomTabsIntent.java:2

* com.auth0.react.A0Auth0Module.showUrl A0Auth0Module.java:5

I can create a PR for this to speed things up as this is causes a lot of issues for us.

@lbalmaceda
Copy link
Contributor

@ar-g I don't think this exception is for the SDK to handle. In the end, the custom tabs dependency will always fallback to a simple ACTION_VIEW intent passing the URL you want to open as data. You could query the package manager for activies that can resolve that action in advance, before launching the web auth. I find hard to believe that nowadays there are still devices without a single browser app installed. but is still valid to check for availability.

@lbalmaceda lbalmaceda added the waiting for customer This issue is waiting for a response from the issue or PR author label Nov 2, 2020
@ar-g
Copy link
Author

ar-g commented Nov 3, 2020

👍 That's a fair point, we can do this on the client-side. But since the library fires an intent I thought that would be more appropriate to do it on the library side.

Regarding nowadays devices, we have the Stacktrace:

androidx.fragment.app.FragmentActivity.startActivityForResult
FragmentActivity.java, line 6
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=https://... (has extras) }
Stack traces
android.app.Instrumentation.checkStartActivityResult Instrumentation.java:2014
android.app.Instrumentation.execStartActivity Instrumentation.java:1675
android.app.Activity.startActivityForResult Activity.java:4601
androidx.fragment.app.FragmentActivity.startActivityForResult FragmentActivity.java:6
android.app.Activity.startActivityForResult Activity.java:4559
androidx.fragment.app.FragmentActivity.startActivityForResult FragmentActivity.java:3
android.app.Activity.startActivity Activity.java:4920
androidx.core.content.ContextCompat.startActivity ContextCompat.java:2
androidx.browser.customtabs.CustomTabsIntent.launchUrl CustomTabsIntent.java:2
com.auth0.react.A0Auth0Module.showUrl A0Auth0Module.java:5
java.lang.reflect.Method.invoke Method.java
com.facebook.react.bridge.JavaMethodWrapper.invoke JavaMethodWrapper.java:18
com.facebook.react.bridge.JavaModuleWrapper.invoke JavaModuleWrapper.java:2
com.facebook.react.bridge.queue.NativeRunnable.run NativeRunnable.java
android.os.Handler.handleCallback Handler.java:873

It only happens on limited set of devices, though, and only Android 9 and 7.1:
LG V35 ThinQ - 25.0%
Nitro_5P - 25.0%
Nokia 2 - 12.5%
Others - 37.5%

@mrarronz
Copy link

mrarronz commented Dec 7, 2020

I have same issue when using react-native-auth0, from the Firebase console, we can see the crashlytics data in last 90 days:

38% - Android 9
22% - Android 10
22% - Android 8
13% - Android 7
5% - Other (2)
40% - samsung
21% - LGE
8% - HUAWEI
5% - motorola
26% - Other (11)

I agree with @ar-g this should be handled on the library side, it's strange to do that on client side that you have to check whether an Android device has a browser which supports custom tab before opening an URL.

@lbalmaceda
Copy link
Contributor

@mrarronz How many devices do that % represent?

Having a browser app installed is one of this library's requirements and there's nothing it can do when a browser app is missing. Yes, we can make that check internally, but you would still need to catch the error code that we raise and decide how you want to proceed. e.g. showing a dialog telling the user to install a browser app.

To be clear, this library does not require a "Custom Tabs compatible" browser app installed. It will always default to any browser app that is available on the device.

I'm tracking this feature request internally under SDK-2224.

@mrarronz
Copy link

mrarronz commented Jan 4, 2021

Screen Shot 2021-01-04 at 11 32 48 AM

Screen Shot 2021-01-04 at 11 39 39 AM

@lbalmaceda This is the crash reported by Firebase in last 90 days, there are over a hundred of users affected by this. With over 10 versions released this issue still exists and even more for latest version.

@lbalmaceda lbalmaceda added needs investigation An issue that has more questions to answer or otherwise needs work to fully understand the issue and removed waiting for customer This issue is waiting for a response from the issue or PR author labels Jan 4, 2021
@lbalmaceda
Copy link
Contributor

Thanks for the details. I've updated the labels to signal this is on our side now.

@stale
Copy link

stale bot commented Apr 7, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you have not received a response for our team (apologies for the delay) and this is still a blocker, please reply with additional information or just a ping. Thank you for your contribution! 🙇‍♂️

@stale stale bot added the closed:stale Issue or PR has not seen activity recently label Apr 7, 2021
@lbalmaceda lbalmaceda removed the closed:stale Issue or PR has not seen activity recently label Apr 7, 2021
@IgorGanapolsky
Copy link

I am facing the same error:

android.content.ActivityNotFoundException
at net.openid.appauth.AuthorizationService.prepareAuthorizationRequestIntent

@lbalmaceda
Copy link
Contributor

@IgorGanapolsky the fix for this is available in 2.8.1. Of course, you would need to capture this error and handle it appropriately. That could imply showing a dialog telling the user they need to download a browser app.

@IgorGanapolsky
Copy link

This issue is still happening when targeting API 31. It has nothing to do with browser being unavailable, as I have Chrome installed on my Android phone....

@ecorengia
Copy link

This is an error from Chrome: GoogleChrome/android-browser-helper#89.

@MaxJadav
Copy link

Reproduce: Android 12 Google device, Or emulator.
Disable all browser from emulator.
App crash when you use this auth0.webAuth.
Add this part in try catch fix my issue in AuthenticationActivity.java -> void onResume() -> launchAuthenticationIntent();

if (!intentLaunched && authenticationIntent.getExtras() == null) {
            finish(); // Activity was launched in an unexpected way
            return;
        } else if (!intentLaunched) {
            try {
                intentLaunched = true;
                launchAuthenticationIntent();
                return;
            } catch (Exception e){
                setResult(RESULT_CANCELED);
                finish();
                return;
            }
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs investigation An issue that has more questions to answer or otherwise needs work to fully understand the issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants