java SysUtils:ApplicationContext 在 ApplicationStatus (WebView) 中为 null

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30013125/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 16:18:15  来源:igfitidea点击:

SysUtils﹕ ApplicationContext is null in ApplicationStatus (WebView)

javaandroidwebview

提问by koras

I can see something strange at WebView based app start. It doesn't affect the app at all but I'm curious why the error appears. Nothing crashes, everything seems to be ok, but the error...

我可以在基于 WebView 的应用程序启动时看到一些奇怪的东西。它根本不会影响应用程序,但我很好奇为什么会出现错误。没有任何崩溃,一切似乎都很好,但是错误...

Here is logcat

这是 logcat

Loading com.google.android.webview version 42.0.2311.137 (code 2311137)
I/LibraryLoader﹕ Time to load native libraries: 2 ms (timestamps 3347-3349)
I/LibraryLoader﹕ Expected native library version number "",actual native library version number ""
V/WebViewChromiumFactoryProvider﹕ Binding Chromium to main looper Looper (main, tid 1) {2d3b4b2c}
I/LibraryLoader﹕ Expected native library version number "",actual native library version number ""
I/chromium﹕ [INFO:library_loader_hooks.cc(112)] Chromium logging enabled: level = 0, default verbosity = 0
I/BrowserStartupController﹕ Initializing chromium process, singleProcess=true
W/art﹕ Attempt to remove local handle scope entry from IRT, ignoring
E/SysUtils﹕ ApplicationContext is null in ApplicationStatus
W/chromium﹕ [WARNING:resource_bundle.cc(286)] locale_file_path.empty()
I/chromium﹕ [INFO:aw_browser_main_parts.cc(63)] Load from apk succesful, fd=34 off=6850672 len=3697
I/chromium﹕ [INFO:aw_browser_main_parts.cc(76)] Loading webviewchromium.pak from, fd:35 off:7953036 len:1161174
I/Adreno-EGL﹕ <qeglDrvAPI_eglInitialize:379>: QUALCOMM Build: 01/15/15, ab0075f, Id3510ff6dc
W/AudioManagerAndroid﹕ Requires BLUETOOTH permission
W/chromium﹕ [WARNING:data_reduction_proxy_config.cc(150)] SPDY proxy OFF at startup
W/art﹕ Attempt to remove local handle scope entry from IRT, ignoring
W/AwContents﹕ onDetachedFromWindow called when already detached. Ignoring
I/GAv4﹕ Google Analytics 4.5.0/7327 is starting up. To enable debug logging on a device run:
    adb shell setprop log.tag.GAv4 DEBUG
    adb logcat -s GAv4

I suppose the error comes from here: https://chromium.googlesource.com/chromium/src/base/+/master/android/java/src/org/chromium/base/SysUtils.java

我想错误来自这里:https: //chromium.googlesource.com/chromium/src/base/+/master/android/java/src/org/chromium/base/SysUtils.java

A few lines of WebView initialisation

几行WebView初始化

...
// load url in webView
webView.loadUrl(webViewUrl);
webView.setWebViewClient(new MyAppWebViewClient());

// implement WebChromeClient inner class
// we will define openFileChooser for select file from camera
webView.setWebChromeClient(new WebChromeClient() {
...

What's going on?

这是怎么回事?

采纳答案by Gergely Bacso

What is happening here is:

这里发生的事情是:

The ApplicationStatus is not initialized yet, so the context cannot be obtained from it. This is a completely natural situation, so no error should be raised. Logging this as an error was an exaggeration from the coder.

ApplicationStatus 尚未初始化,因此无法从中获取上下文。这是完全自然的情况,因此不应引发错误。将此记录为错误是编码人员夸大其词。

However:

然而:

This does not cause any real problem, because the function tries to get a context object only to perform yet another check to assess the performance capabilities of the device. Since it sometimes fails to call the "isLowRamDevice()", it will just carry on performing the rest of the checks. So worst case scenario is not being able to detect a low-end phone at this point, and subsequent checks will be made.

这不会导致任何实际问题,因为该函数尝试获取上下文对象只是为了执行另一次检查以评估设备的性能能力。由于它有时无法调用“isLowRamDevice()”,它只会继续执行其余的检查。因此,最坏的情况是此时无法检测到低端手机,并将进行后续检查。

Also it is completely normal that "I see this error in a Lollipop device (Nexus 10) but not in a JellyBean device", because the function has an early return if it detects anything below KitKat. (// Any pre-KitKat device cannot be considered 'low-end')

这也是完全正常的 "I see this error in a Lollipop device (Nexus 10) but not in a JellyBean device",因为如果函数检测到低于 KitKat 的任何内容,它会提前返回。( // Any pre-KitKat device cannot be considered 'low-end')