Description
Did you verify this is a real problem by searching the NativeScript Forum
https://discourse.nativescript.org/t/webview-causes-app-crash-on-android-with-chrome-67-release/6202
Tell us about the problem
With the latest chrome (67.0.3396.68) update on Android 8.1.0 webview is crashing.
Please provide the following version numbers that your issue occurs with:
- CLI: 3.4.2
- tns-android: 3.4.2
- Android: 8.1.0
- Chromium: 67.0.3396.68
After further debugging,
Invoking of onReceivedError on webviewclient is causing the null pointer exception in Runtime.java (https://github.com/NativeScript/android-runtime/blob/v3.4.2/test-app/runtime/src/main/java/com/tns/Runtime.java), Line number 682: (String pname = p.getName();)
After the chrome update on the device, the 2nd(android.webkit.WebResourceRequest) and 3rd (android.webkit.WebResourceError) parameters of function onReceivedError of WebViewClient received object whose class is having empty package. This causes line 679 of https://github.com/NativeScript/android-runtime/blob/v3.4.2/test-app/runtime/src/main/java/com/tns/Runtime.java [clazz.getPackage();] to return null. And subsequently this causes null pointer exception on line 682 of same file [ String pname = p.getName(); ] .
Printing the class names inside the function getTypeMetadata, with latest chrome as webview, gives class vS, class vR.
But in the device if I select to use android webview instead of chrome webview, it gives class as com.android.webview.chromium.xz, com.android.webview.chromium.WL.
So essentially the function getTypeMetadata is not handling classes with empty packages.
So instaed of:
Package p = (mostOuterClass != null)
? mostOuterClass.getPackage()
: clazz.getPackage();
int packageCount = 1;
String pname = p.getName();
changing to:
Package p = (mostOuterClass != null)
? mostOuterClass.getPackage()
: clazz.getPackage();
int packageCount = p != null ? 1 : 0;
String pname = p != null ? p.getName() : "";
This seems to be fixing the issue.