如何使用 WebView 启用 WebKit 的 Android 应用程序远程调试/检查器? [英] how to enable WebKit's remote debugging/inspector of Android app using WebView?

查看:25
本文介绍了如何使用 WebView 启用 WebKit 的 Android 应用程序远程调试/检查器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要检查 android 应用程序中的 javascript 执行(webview 小部件),调试时;通过 SDK &USB 电缆和/或 http/websockets;从桌面计算机(例如在桌面上运行的 chrome).

I need to inspect javascript execution (webview widget) in an android application, while debugging; through SDK & usb cable and/or http/websockets; from destop computer (e.g. chrome running on desktop).

Webkit 的源代码包括 DebuggerServer 实现( platform_external_webkitSourceWebKitandroidwdsDebugServer.cpp )可在 cpp 级别访问,并在启用标志 WDS 时绑定(在构建时?)

Webkit's sources includes DebuggerServer implementation ( platform_external_webkitSourceWebKitandroidwdsDebugServer.cpp ) accessible at cpp level, and bound if flag WDS is enabled (at build time?)

SourceWebKitandroidjniWebCoreFrameBridge.cpp:#if ENABLE(WDS)SourceWebKitandroidjniWebCoreFrameBridge.cpp: WDS::server()->addFrame(frame);

SourceWebKitandroidjniWebCoreFrameBridge.cpp:#if ENABLE(WDS) SourceWebKitandroidjniWebCoreFrameBridge.cpp: WDS::server()->addFrame(frame);

服务器默认端口为 9999

The default port for server is 9999

消息来源显示所有内容都已实现(在 Cpp 级别)以启用该功能,但我在网上搜索经验时没有找到任何参考资料在 javascript 级别的 android 设备自动化中使用实时调试webkit 的检查器界面.

The sources show that all is implemented (at Cpp level) to enable the feature, but I have not found any reference searching the web for experiences using live debugging at javascript level in adroid devices automating webkit's inspector interface.

1.- 该功能是否以二进制形式存在于实际的安卓设备中?(是否在未启用 WDS 标志的情况下构建了 android 的 webkit 分发?:-( )

1.- Are the feature present, in binary form, executing in actual android devices? (has adroid's distribution of webkit been built without WDS flag enabled? :-( )

2.- 可以从 javascript 或应用程序启用/使用远程调试功能吗(在java级别)例如应用启动时?

2.- Can the remote debug feature be enabled/used from javascript or application (at java level) e.g. at startup of app?

3.- 如果可以启用 webkit 检查器/调试器功能,如何使与远程应用程序交互成为可能?(例如从另一个使用 websockets 的 javascript 应用程序,或台式计算机上的 chrome).

3.- In case it is possible to enable the webkit inspector/debugger feature, how to make it possible to interact from remote application ? (e.g. from another javascript app using websockets, or chrome on desktop computers).

一些解释机制的段落,如https://developers.google.com/chrome-developer-tools/docs/remote-调试#远程会很好!

Some paragraphs explaining the mechanics like https://developers.google.com/chrome-developer-tools/docs/remote-debugging#remote would be nice!

预先感谢您提供有关此主题的任何信息或参考.我认为在以下位置启用远程调试(在设备中)很重要javascript 级别,使 HTML5 的现代开发成为可能应用程序和愉快的调试体验.

thanks in advance for any information, or references about this topic. I consider important to enable remote debugging (in the device) at javascript level to make it possible modern development of HTML5 applications and happy debugging experience.

干杯,啤酒.

推荐答案

对于安卓 >= 4.4 (kitkat)

请参阅使用 Chrome 在 Android 上进行远程调试

对于安卓 <4.4(低版本)

使用非常好的开源工具:weinre.请参阅视频以获取使用帮助.如果你熟悉 grunt 那么你可以使用 grunt-weinre

Use very good open source tool: weinre. See this video for help to use it. If you are familiar with grunt then you can use grunt-weinre

快速查看:

  1. 使用 npm 安装 weinre
  2. 在您的 gruntfile 中进行配置.
  3. 运行 weinre grunt 任务.
  4. 使用此脚本将 weinre 目标代码注入您的网页.

  1. 在浏览器中打开 http://localhost:8082,您会发现设备在上面运行脚本.您可以调试所有这些设备.
  1. Open http://localhost:8082 in your browser and you will find devices running above script. You can debug all this devices.

注意:如果您想在移动设备中调试 webview/浏览器,那么您需要将 localhost 替换为运行 weinre 的机器 IP.是的,所有设备都应该在同一个网络上.

NOTE: if you want to debug webview/browser in your mobile device then you need to replace localhost with your machine's IP running weinre. And yes, all the devices should be on the same network.

这篇关于如何使用 WebView 启用 WebKit 的 Android 应用程序远程调试/检查器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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