I'm using TrustedWebActivities and I'm getting an immediate app crash on Samsung S8, S9, and Pixel 2 devices with the below Exception. Some research suggests that this might happen on devices where there's an older version of Chrome installed which doesn't support TWA and the fall-back method fails. But I've confirmed that the Chrome version is 71 (also, this works on Samsung S7, Pixel 3).
java.lang.NullPointerException:
at android.support.customtabs.TrustedWebUtils.launchAsTrustedWebActivity (TrustedWebUtils.java:91)
at android.support.customtabs.trusted.LauncherActivity$TwaCustomTabsServiceConnection.onCustomTabsServiceConnected (LauncherActivity.java:192)
at android.support.customtabs.CustomTabsServiceConnection.onServiceConnected (CustomTabsServiceConnection.java:44)
at android.app.LoadedApk$ServiceDispatcher.doConnected (LoadedApk.java:1656)
at android.app.LoadedApk$ServiceDispatcher$RunConnection.run (LoadedApk.java:1685)
at android.os.Handler.handleCallback (Handler.java:789)
at android.os.Handler.dispatchMessage (Handler.java:98)
at android.os.Looper.loop (Looper.java:164)
at android.app.ActivityThread.main (ActivityThread.java:6938)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run (Zygote.java:327)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1374)
I believe this is happening on this line where session
is null, which is an object of type CustomTabsSession
. Here's the source.
session.validateRelationship(CustomTabsService.RELATION_HANDLE_ALL_URLS, uri, null);
Any help is appreciated. Thank you.