如何在模拟器(Android 5)中升级Android的Webview [英] How to upgrade Android's Webview in Emulator (Android 5)

查看:87
本文介绍了如何在模拟器(Android 5)中升级Android的Webview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Android 5.0.0似乎不接受Web View更新.也就是说,Android系统Webview可以从Play商店正常安装(链接).但是,浏览器继续使用旧的WebView(根据用户代理字符串).

Android 5.0.0 running in emulator appears to not take Web View updates. That is, Android System Webview installs just fine from the Play Store (link). However, the browser continues to use the older stock WebView (according to the user-agent string).

为什么在模拟器中不进行webview升级,怎么办?

Why isn't webview upgrading in the emulator and how can it be done?

P.S.升级显示为与现有WebView一起安装(均显示在应用程序列表中).尝试通过Play商店进行安装,但无济于事.

P.S. The upgrade appears installed alongside the stock WebView (both show up in the list of applications). Tried installing via Play Store and manually to no avail.

P.P.S.这样做的目的是测试我的代码如何处理特定版本的Webview中的特定错误.

P.P.S. The purpose of this is to test how my code handles a particular bug in a certain version of webview.

推荐答案

5岁的问题,但我昨天找到了它,并且经过一番修补后得以解决.

5 year old question, and yet I found it yesterday and got to solve it after some tinkering.

首先,关于为什么无法从Play商店安装Webview的问题,请参见此问题.简而言之,模拟器使用 com.android.webview ,而Google Play安装 com.google.android.webview .而且(我所知道的)没有办法将模拟器配置为使用Google的Webview.因此,使用Play商店是死胡同.

First, as to why installing the webview from the play store doesn't work, that is answered in this question. In a nutshell, the emulator is using com.android.webview whilst google play installs com.google.android.webview. And there is no way (that I know of) to configure the emulator to use Google's webview. So using the play store is a dead end.

我可以实现的是卸载默认的Webview并安装更新的版本.我无法对其进行升级,因为为新的Webview获得的apk与已安装的apk具有不同的签名.但是卸载也不是很简单,因为webview是一个系统应用程序,您将无法运行 adb uninstall 来卸载它.

What I could achieve though is uninstall the default webview and install a newer version. I wasn't able to just upgrade it because the apk I got for the new webview had a different signature from the one installed. But uninstalling isn't straightforward either, because the webview is a system app and you won't be able to uninstall it running adb uninstall.

这就是我所做的:

# Boot the emulator in write mode and make /system writable
emulator @DeviceName -writable-system
adb remount

# Uninstall the webview app manually and reboot the device
adb shell
rm -rf /data/data/com.android.webview
rm -rf /system/app/webview
reboot

# Install the new version
adb install webview.apk

此方法的一个缺点是您需要以写入模式启动设备以进行后续运行(尽管无需再次运行 adb remount ).但这有效!

One drawback of this approach is that you'll need to boot your device in write mode for subsequent runs (no need to run adb remount again though). But it works!

如果您想知道,我从

In case you're wondering, I got the apk for the new version from Google's source (no need to compile manually).

这篇关于如何在模拟器(Android 5)中升级Android的Webview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆