1.When I in Fragment onCreateView method inflater.inflate(webview_layout, container, false) on Android 9 may Crash with blow log:
Fatal Exception: java.lang.RuntimeException:Using WebView from more than one process at once with the same data directory is not supported. https://crbug.com/558377 at jO.b(PG:102) at jQ.run(PG:3) at android.os.Handler.handleCallback(Handler.java:873) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:226) at android.app.ActivityThread.main(ActivityThread.java:7210) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:499) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:961)
2.I try add blow code in Application onCreate method
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
String processName = getProcessName();
if (!MAIN_PROCESS.equals(processName)) {
WebView.setDataDirectorySuffix(getProcessName() + ".webview");
}
}
but some Android mobile phone alse Crash with same reason,and I don't use webview with multi process, then I try add this code in Fragment onCreateView before inflater.inflate(webview_layout, container, false)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
String processName = getProcessName();
try {
WebView.setDataDirectorySuffix(processName);
} catch (Throwable e) {
// ignore
}
}
But I also get some the same crash report in PCAM10\PCEM00\PCAT10... and I can't reappear this crash local.
Is also some other reason with this Crash?