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

IllegalArgumentException in CustomTabsClient #138

Closed
billgockeler opened this issue Jan 2, 2018 · 17 comments · Fixed by #169
Closed

IllegalArgumentException in CustomTabsClient #138

billgockeler opened this issue Jan 2, 2018 · 17 comments · Fixed by #169

Comments

@billgockeler
Copy link

We're experiencing the following crash in production:

Fatal Exception: java.lang.RuntimeException: Unable to resume activity {tv.fubo.mobile/com.auth0.android.provider.AuthenticationActivity}: java.lang.IllegalArgumentException: Service Intent must be explicit: Intent { act=android.support.customtabs.action.CustomTabsService }
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3535)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3575)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2817)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1528)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6316)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:872)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:762)
Caused by java.lang.IllegalArgumentException: Service Intent must be explicit: Intent { act=android.support.customtabs.action.CustomTabsService }
at android.app.ContextImpl.validateServiceIntent(ContextImpl.java:1347)
at android.app.ContextImpl.bindServiceCommon(ContextImpl.java:1459)
at android.app.ContextImpl.bindService(ContextImpl.java:1427)
at android.content.ContextWrapper.bindService(ContextWrapper.java:636)
at android.support.customtabs.CustomTabsClient.bindCustomTabsService(CustomTabsClient.java:70)
at com.auth0.android.provider.CustomTabsController.bindService(CustomTabsController.java:97)
at com.auth0.android.provider.AuthenticationActivity.launchAuthenticationIntent(AuthenticationActivity.java:111)
at com.auth0.android.provider.AuthenticationActivity.onResume(AuthenticationActivity.java:76)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1270)
at android.app.Activity.performResume(Activity.java:6861)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3512)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3575)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2817)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1528)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6316)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:872)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:762)

@lbalmaceda
Copy link
Contributor

Same as the the other issue: Please share steps to reproduce and the context in which this has happened, such as the android version or whether a "Custom Tabs" compatible app was installed in that device at the time this exception was thrown.

@billgockeler
Copy link
Author

Sorry, we don't have steps to reproduce, we only see intermittent crashes in our app cause by this. We're not using Custom Tabs at all.

The underlying problem with these two issues seems to be that launchAuthenticationIntent() is getting called when the bundle extras are not available. It looks like that shouldn't be happening with your check of '!intentLaunched' - nevertheless it's happening.

@lbalmaceda
Copy link
Contributor

I'm closing this due to missing repro steps. See if the issue continues to happen with the latest patch and re-open it if necessary.

@vanshg
Copy link

vanshg commented Feb 20, 2018

+1, I'm getting this crash as well in crash reports. I can't reproduce personally. Though, I just updated my auth0 version, so it may go away (I was using the version bundled with Lock before)

@tplkn
Copy link

tplkn commented Apr 24, 2018

@lbalmaceda
To avoid this compile error, developers can add support library
implementation "com.android.support:customtabs:$supportLibraryVersion"
due to support libraries version conflicts some of them can exclude support libraries from this library.
For example

implementation ('com.auth0.android:auth0:1.12.2') {
    exclude group: 'com.android.support'
}

@lbalmaceda
Copy link
Contributor

@tplkn thanks. That's a known solution for conflicting dependency versions, but I don't think the exception in the original post is that case. If the rest can leave some feedback it would be appreciated.

@billgockeler
Copy link
Author

@lbalmaceda We've updated to 1.12.1 back in Feb but this crash is still occurring and is the most frequent crash on our app. We still cannot repro the error internally. The stack trace is still the same as above.
The only other information we have is that this occurs only on Android version 5 & 7.

Please re-open this issue. Perhaps some other customers will be able to provide more info.

@lbalmaceda lbalmaceda reopened this May 29, 2018
@jeffbuswell
Copy link

@lbalmaceda We are also seeing this crash, using auth0 version 1.13.0

Caused by java.lang.IllegalArgumentException: Service Intent must be explicit: Intent { act=android.support.customtabs.action.CustomTabsService }
       at android.app.ContextImpl.validateServiceIntent(ContextImpl.java:1345)
       at android.app.ContextImpl.bindServiceCommon(ContextImpl.java:1454)
       at android.app.ContextImpl.bindService(ContextImpl.java:1422)
       at android.content.ContextWrapper.bindService(ContextWrapper.java:636)
       at android.support.customtabs.CustomTabsClient.bindCustomTabsService(CustomTabsClient.java:71)
       at com.auth0.android.provider.CustomTabsController.bindService(CustomTabsController.java:97)
       at com.auth0.android.provider.AuthenticationActivity.launchAuthenticationIntent(AuthenticationActivity.java:115)
       at com.auth0.android.provider.AuthenticationActivity.onResume(AuthenticationActivity.java:80)
       at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1291)
       at android.app.Activity.performResume(Activity.java:6802)
       at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3439)
       at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3502)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2761)
       at android.app.ActivityThread.-wrap12(ActivityThread.java)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1495)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:154)
       at android.app.ActivityThread.main(ActivityThread.java:6196)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:888)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:778)

@lbalmaceda
Copy link
Contributor

I think there's a tiny chance that the user doesn't have any browser-like app installed (how do they live?!). I'll try to make a PR to validate this and get a patch release for the next week. Hang on!!

@jeffbuswell
Copy link

@lbalmaceda Yep, I disabled the browser on an emulator and sure enough, I got the same crash.

@jeffbuswell
Copy link

@lbalmaceda It might also be that there is no supported customtabs browser?

@lbalmaceda
Copy link
Contributor

@jeffbuswell No, that's not the case since we first get all browser apps and keep only those who respond successfully to the CustomTabs Connection service. Then we choose one from that list, taking the user preference into account first and then falling back to the ones we trust the most. But if no app matches, we default to the one the OS would pick to open a generic ACTION_VIEW url intent. The thing is initially that value is null and only gets set if that ACTION_VIEW intent succeeds. So in the end, if no browser is installed there's nothing this class or even the SDK could do to open a URL (not even talking about using custom tabs anymore, just plain browsing).

The most I can do is capture that and silently log an error, or throw an unchecked exception (but this is already done by the OS). Otherwise this would be a breaking change (requiring devs to try/catch the call) and to be honest all phones should have at least 1 browser app installed.

@billgockeler
Copy link
Author

billgockeler commented Jul 6, 2018

@jeffbuswell Thanks for contributing with your info that helped @lbalmaceda find the fix. This has been a thorn in our side for some time. Please shoot me a note when the fix is posted. Thanks!

@billgockeler
Copy link
Author

billgockeler commented Jul 19, 2018

@lbalmaceda We're testing this fix. You've successfully handled the case when no browser is installed. Thank you. We also tested the condition where the installed browser doesn't support custom tabs and are getting the following crash while you're unbinding the service. We used Opera and Opera mini for our testing.

`07-19 12:23:09.304 30141-30141/tv.fubo.mobile.debug V/CustomTabsController: Trying to bind the service
Bind request result: false
07-19 12:23:09.305 30141-30312/tv.fubo.mobile.debug D/CustomTabsController: Launching URI. Custom Tabs available: false
07-19 12:23:09.420 30141-30146/tv.fubo.mobile.debug I/zygote: Do full code cache collection, code=252KB, data=216KB
07-19 12:23:09.422 30141-30146/tv.fubo.mobile.debug I/zygote: After code cache collection, code=227KB, data=144KB
07-19 12:23:09.574 30141-30226/tv.fubo.mobile.debug D/OpenGLRenderer: endAllActiveAnimators on 0x89e0c300 (InsetDrawable) with handle 0x9036f1d0
07-19 12:23:09.607 30141-30223/tv.fubo.mobile.debug E/UserPrefs: user not found
07-19 12:23:11.365 30141-30141/tv.fubo.mobile.debug V/CustomTabsController: Trying to unbind the service
07-19 12:23:11.365 30141-30141/tv.fubo.mobile.debug D/AndroidRuntime: Shutting down VM

--------- beginning of crash

07-19 12:23:11.369 30141-30141/tv.fubo.mobile.debug E/AndroidRuntime: FATAL EXCEPTION: main
Process: tv.fubo.mobile.debug, PID: 30141
java.lang.RuntimeException: Unable to destroy activity {tv.fubo.mobile.debug/com.auth0.android.provider.AuthenticationActivity}: java.lang.IllegalArgumentException: Service not registered: com.auth0.android.provider.CustomTabsController@6accc92
at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:4482)
at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:4500)
at android.app.ActivityThread.-wrap5(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1667)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6592)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:769)
Caused by: java.lang.IllegalArgumentException: Service not registered: com.auth0.android.provider.CustomTabsController@6accc92
at android.app.LoadedApk.forgetServiceDispatcher(LoadedApk.java:1475)
at android.app.ContextImpl.unbindService(ContextImpl.java:1637)
at android.content.ContextWrapper.unbindService(ContextWrapper.java:697)
at com.auth0.android.provider.CustomTabsController.unbindService(CustomTabsController.java:109)
at com.auth0.android.provider.AuthenticationActivity.onDestroy(AuthenticationActivity.java:95)
at android.app.Activity.performDestroy(Activity.java:7186)
at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1270)
at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:4469)
at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:4500) 
at android.app.ActivityThread.-wrap5(Unknown Source:0) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1667) 
at android.os.Handler.dispatchMessage(Handler.java:105) 
at android.os.Looper.loop(Looper.java:164) 
at android.app.ActivityThread.main(ActivityThread.java:6592) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:769) 
`

@lbalmaceda
Copy link
Contributor

@billgockeler ah this was a silly mistake. I forgot to check the service was bound 🤦‍♂️ Let me create a quick patch.

@lbalmaceda
Copy link
Contributor

@billgockeler PR is there but circleci is still having issues. I'll make a patch release as soon as I can. 👍

@billgockeler
Copy link
Author

perfect, thanks for the prompt response...yeah, we're currently held up by circleci as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants