Platform: RK3288
OS: Android 7.1.2
Kernel: v4.4.143
需求:
升级高版本的WebView Apk;客户端播放网页,显示不正常;安装高版本的谷歌浏览器手动打开网页,显示正常;Android5.1开始,WebView具体实现从框架层剥离出来,通过一个包名来控制加载真正的WebView实现;开发应用打开网页端调用就是系统的webview,我们要做的将系统WebView Apk升级到高版本;
手动调试:
查阅RK 官方文档:浏览器FAQ.pdf
文档的意思是先卸载掉 com.google.android.webview和com.android.webview两个WebView Apk。以及删除相关文件后手动安装新的WebView Apk;
google.android.webview下载地址:手机乐园
当时想着一步到位,下载当前最新的版本Android System WebView v86.0.4240.198
报错如下信息
Failure [INSTALL_FAILED_OLDER_SDK: Failed parse during installPackageLI: /data/app/vmdl647133596.tmp/base.apk (at Binary XML file line #4): Requires newer sdk version #29 (current version is #25)]
这个APK最低Android系统要求Android10 (API 版本 29),退而求其次下载安装ASWebView_V85.0.4183.81
安装成功之后打开网页APK直接闪退,闪退日志如下:
01-13 18:47:40.690 W/WebViewUpdateServiceImpl( 422): creating relro file timed out
01-13 18:47:40.696 E/WebViewFactory( 1476): Chromium WebView package does not exist
01-13 18:47:40.696 E/WebViewFactory( 1476): android.webkit.WebViewFactory$MissingWebViewPackageException: Failed to load WebView provider: No WebView installed
01-13 18:47:40.696 E/WebViewFactory( 1476): at android.webkit.WebViewFactory.getWebViewContextAndSetProvider(WebViewFactory.java:270)
01-13 18:47:40.696 E/WebViewFactory( 1476): at android.webkit.WebViewFactory.getProviderClass(WebViewFactory.java:330)
01-13 18:47:40.696 E/WebViewFactory( 1476): at java.lang.reflect.Method.invoke(Native Method)
01-13 18:47:40.696 E/WebViewFactory( 1476): at com.signway.droid.utils.PublicTools.hookWebView(PublicTools.java:2898)
01-13 18:47:40.696 E/WebViewFactory( 1476): at com.signway.droid.SessionApplication.onCreate(SessionApplication.java:146)
01-13 18:47:40.696 E/WebViewFactory( 1476): at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1024)
01-13 18:47:40.696 E/WebViewFactory( 1476): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5425)
01-13 18:47:40.696 E/WebViewFactory( 1476): at android.app.ActivityThread.-wrap2(ActivityThread.java)
01-13 18:47:40.696 E/WebViewFactory( 1476): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1551)
01-13 18:47:40.696 E/WebViewFactory( 1476): at android.os.Handler.dispatchMessage(Handler.java:102)
01-13 18:47:40.696 E/WebViewFactory( 1476): at android.os.Looper.loop(Looper.java:154)
01-13 18:47:40.696 E/WebViewFactory( 1476): at android.app.ActivityThread.main(ActivityThread.java:6141)
01-13 18:47:40.696 E/WebViewFactory( 1476): at java.lang.reflect.Method.invoke(Native Method)
01-13 18:47:40.696 E/WebViewFactory( 1476): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912)
01-13 18:47:40.696 E/WebViewFactory( 1476): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:802)
在其他项目上找了个包名为com.android.webview的安装包,用手动的方式可以安装并成功打开,猜测是系统的某个配置文件对包名 com.google.android.webview和com.android.webview进行了选配,其中默认的包名为com.android.webview;
实现:
文件:/external/chromium-webview/prebuilt/arm
替换目录下的webview.apk文件
文件:/frameworks/base/core/res/res/xml/config_webview_packages.xml
diff --git a/core/res/res/xml/config_webview_packages.xml b/core/res/res/xml/config_webview_packages.xml
old mode 100644
new mode 100755
index f062b59..9c4d65a
--- a/core/res/res/xml/config_webview_packages.xml
+++ b/core/res/res/xml/config_webview_packages.xml
@@ -16,6 +16,6 @@<webviewproviders><!-- The default WebView implementation -->
- <webviewprovider description="Android WebView" packageName="com.android.webview" availableByDefault="true">
+ <webviewprovider description="Android WebView" packageName="com.google.android.webview" availableByDefault="true"></webviewprovider></webviewproviders>
小知识:
打开这个网站可以查看当前浏览器的WebView版本:浏览迷