问题描述:

硬件测试ETT时,运行MTK的NenaMark2.apk出现FC
错误信息如下:

01-01 00:17:53.989  3569  3569 E AndroidRuntime: FATAL EXCEPTION: main
01-01 00:17:53.989  3569  3569 E AndroidRuntime: Process: se.nena.nenamark2, PID: 3569
01-01 00:17:53.989  3569  3569 E AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{se.nena.nenamark2/se.nena.nenamark2.NenaMark2}: android.view.InflateException: Binary XML file line #19: Binary XML file line #19: Error inflating class android.webkit.WebView
01-01 00:17:53.989  3569  3569 E AndroidRuntime: 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2897)
01-01 00:17:53.989  3569  3569 E AndroidRuntime: 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2975)
......
01-01 00:17:53.989  3569  3569 E AndroidRuntime: Caused by: android.view.InflateException: Binary XML file line #19: Binary XML file line #19: Error inflating class android.webkit.WebView
01-01 00:17:53.989  3569  3569 E AndroidRuntime: Caused by: android.view.InflateException: Binary XML file line #19: Error inflating class android.webkit.WebView
01-01 00:17:53.989  3569  3569 E AndroidRuntime: Caused by: java.lang.reflect.InvocationTargetException
01-01 00:17:53.989  3569  3569 E AndroidRuntime: 	at java.lang.reflect.Constructor.newInstance0(Native Method)
01-01 00:17:53.989  3569  3569 E AndroidRuntime: 	at java.lang.reflect.Constructor.newInstance(Constructor.java:334)
......
01-01 00:17:53.989  3569  3569 E AndroidRuntime: Caused by: android.util.AndroidRuntimeException: android.webkit.WebViewFactory$MissingWebViewPackageException: Failed to load WebView provider: No WebView installed
01-01 00:17:53.989  3569  3569 E AndroidRuntime: 	at android.webkit.WebViewFactory.getProviderClass(WebViewFactory.java:456)
01-01 00:17:53.989  3569  3569 E AndroidRuntime: 	at android.webkit.WebViewFactory.getProvider(WebViewFactory.java:192)
01-01 00:17:53.989  3569  3569 E AndroidRuntime: 	at android.webkit.WebView.getFactory(WebView.java:2530)
01-01 00:17:53.989  3569  3569 E AndroidRuntime: 	at android.webkit.WebView.ensureProviderCreated(WebView.java:2525)
01-01 00:17:53.989  3569  3569 E AndroidRuntime: 	at android.webkit.WebView.setOverScrollMode(WebView.java:2590)
......
01-01 00:17:53.989  3569  3569 E AndroidRuntime: Caused by: android.webkit.WebViewFactory$MissingWebViewPackageException: Failed to load WebView provider: No WebView installed
01-01 00:17:53.989  3569  3569 E AndroidRuntime: 	at android.webkit.WebViewFactory.getWebViewContextAndSetProvider(WebViewFactory.java:352)
01-01 00:17:53.989  3569  3569 E AndroidRuntime: 	at android.webkit.WebViewFactory.getProviderClass(WebViewFactory.java:416)
01-01 00:17:53.989  3569  3569 E AndroidRuntime: 	... 43 more

解决思路:

看log发现是WebView丢失,然后一直还在纠结好好的WebView怎么丢失了。研究发现Developer options中WebView implementation显示None,正常应该显示Chrome。
根本原因就在frameworks/base/core/res/res/xml/config_webview_packages.xml文件中。在这个文件中需要对使用的webview进行声明,一般系统默认的是com.android.webview,但是看文件中取消了com.android.webview,而是使用Chrome中自带的Webview和WebviewGoogle。但当前硬件测试的版本是没有集成Chrome和WebviewGoogle的,所以就会造成WebView丢失。

解决办法:

若frameworks/base/core/res/res/xml/config_webview_packages.xml文件中有对Chrome的声明,直接将Chrome集成到系统中就行。

<webviewproviders>
    <!-- The default WebView implementation -->
    <!--<webviewprovider description="Android WebView" packageName="com.android.webview" availableByDefault="true">
    </webviewprovider>-->
    <webviewprovider description="Chrome Stable" packageName="com.android.chrome" availableByDefault="true">
        <!-- Ignore this package on user/release builds unless preinstalled. -->
    </webviewprovider>
    <webviewprovider description="Google WebView" packageName="com.google.android.webview" availableByDefault="true" isFallback="true">
        <!-- Ignore this package on user/release builds unless preinstalled. -->
    </webviewprovider>

题外:

关于更新chrome,必须也更新webviewgoogle

另外还有可能是客户自己杀死了webview进程。

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐