我在做一个和拉斐尔有关的项目。事实证明,它在Android上不起作用。iPhone上是这样的。

我该怎么调试Android浏览器上的东西呢?它是WebKit,所以如果我知道版本,在完整版本的WebKit上调试它会产生相同的结果吗?


当前回答

我的解决方案是(对于普通浏览器):

股票的浏览器 " console .log"导入JS源代码 启用调试USB Android SDK 来自Android SDK: monitor.bat 监控过滤器作为附加的图像

其他回答

试一试:

打开要调试的页面 而在该页面上,在普通Android浏览器的地址栏中输入: :调试 (注意什么都没有发生,但是启用了一些新的选项。)

在我试过的设备上都有效。阅读更多关于Android浏览器:调试,这些设置做什么?

编辑: 在脚本中添加以下代码也有助于检索更多信息,如行号:

window.onerror = function (message, url, lineNo){
    console.log('Error: ' + message + '\n' + 'Line Number: ' + lineNo);
    return true;
}

仅供参考,RaphaelJS不能在android上运行的原因是android webkit(不像iPhone webkit)此时不支持SVG。谷歌最近才得出结论,SVG支持android是一个好主意,所以它在一段时间内还不会可用。

看一看jsHybugger。它将允许你远程调试你的js代码:

Android混合应用(webview, phonegap, worklight) Web页面运行在默认的android浏览器(不是Chrome,它支持ADB扩展没有这个工具)

这是如何工作的(在项目网站上有更多的细节和替代方案,这是我发现的最好的方法)。

Install the jsHybugger APK on your device Enable USB debugging on you device. Plug the Android device into your desktop computer via USB Run the app on the Android device ('jsHybugger') Enter the target URL and page in the app. Press Start Service and finally Open Browser You'll be presented with a list of installed browsers, choose one. The browser launches. Back on your desktop computer open Chrome to chrome://inspect/ An inspectors window will appear with the chrome debugging tools linked to the page on the Android device. debug away!

同样,在Android上使用Chrome使用ADB扩展而不使用jsHybugger。我想这个问题的公认答案已经描述过了。

没有人提到liriliri/eruda,它为移动网站/应用程序添加了自己的调试工具

将此添加到您的页面:

<script src="//cdn.jsdelivr.net/npm/eruda"></script>
<script>eruda.init();</script>

将在打开控制台的页面中添加一个浮动图标。

“Kiwi浏览器”拥有与桌面chrome浏览器相同的工具,并且可以在android上进行本地调试-不需要usb。 加载html文件,并在菜单中选择“开发人员工具”。如果需要重新启动调试,请重新加载html。