=
Debugging is the core of development efficiency.
I feel that the current tools are really difficult to use. Although they can be used, they are only "available".
=
1. Debug h5 page
This is the easiest way to install the Android version of chrome on the Android phone, connect to the PC via USB, and then open chrome://inspect in the PC's chrome browser.
If the above is too simple, I paste a detailed:
Debug the mobile webview through Chrome's inspect
二、调试app的内部组件
使用ANDROID_HOME\tools\uiautomatorviewer工具
三、调试app的webkit的webview
从 Android 4.4 开始,webkit是支持远程调试的,不过需要将app的debug模式打开,可以使用如下代码:
WebView.setWebContentsDebuggingEnabled(true);
由于大部分 App 的 debug 模式是关闭的,即便是内部 App,比如 QQ/微信,要去找一个开启了debug 模式的版本还是比较麻烦的。因此需要使用借助第三方工具来强制开启任何 App 的 Android webview debug模式,使之可以使用 chrome inspect。而这个工具就是 Xposed 。
我们已经提供了一份要安装的文件,请首先到 https://github.com/feix760/WebViewDebugHook 下载文件。
Xposed的具体使用参考:
http://blog.csdn.net/zhulin2609/article/details/51437821
Android4.4及以下低版本使用Xposed:
http://repo.xposed.info/module/de.robv.android.xposed.installer
Android5.0及以上高版本使用Xposed:
https://forum.xda-developers.com/showthread.php?t=3034811
1、root设备
因为涉及到 root 权限,因此需要将手机进行 root。有很多工具可以来 root,比如KingRoot、一键root、360一键root等。如果你安装了QQ电脑管家,可以在“电脑管家-工具箱-其他”列表里面看到KingRoot。
2、安装xposed框架
在下载文件的hook.zip中,找到 de.robv.android.xposed.installer_v33_36570c.apk,安装之。也可以去 官网 下载。
3、安装xposed webview debugging模块
在下载文件的hook.zip中,找到 WebViewDebugHook.apk,安装之。
4、激活Xposed
安装后上述两个apk之后,可以看到手机上面出现了一个叫 Xposed Installer 的图标,点击进去之后会看到提示说Xposed未激活,点击红色字体部分,会切换到另外一条页面,点击“安装/更新”按钮即可。
但有部分手机会出现类似如下的错误,导致无法点击“安装/更新”,目前已知的是部分版本的MIUI是会出现这个问题的。
安装完成之后,重启再打开,再点击刚才点击过的地方,切入页面之后,勾选,再重启,重启之后即激活了Xposed。
5、关于QQ等(别折腾增了,过时了,请看下一篇文章)
QQ等默认会使用X5内核,把下载文件中的 debug.conf 放在sd卡根目录下就可以强制它使用 Android 自带 webview 。
-
Tencent QQ use it's X5 kernel, and could not debugging. We can make a file named
debug.conf
with blow content in the root directory to force it use webview.
result_QProxy=false
result_systemWebviewForceUsed=true
setting_forceUseSystemWebview=true
6、测试
手机usb连接电脑,使用 chrome 打开 chrome://inspect ,然后打开任意 App 的 webview ,接下来就是见证奇迹的时候了。
参考:
1.强制开启android webview debug模式使用Chrome inspect
http://blog.csdn.net/zhulin2609/article/details/51437821
2.Google官方文档:https://developers.google.com/web/tools/chrome-devtools/debug/remote-debugging/remote-debugging
=
=
=