有没有办法在 Android 中为 Safari 启用 JavaScript 错误/调试控制台?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/468993/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is there a way to enable the JavaScript Error/Debug Console for Safari within Android?
提问by Kevin
I'm developing a JavaScript application that needs to run on the Google Android Phone OS. Is there a way to enable the JavaScript Error/Debug console within Safari on either the Android Emulator or an actual device? If so any instructions on how to do so would be appreciated.
我正在开发一个需要在 Google Android 手机操作系统上运行的 JavaScript 应用程序。有没有办法在 Android 模拟器或实际设备上的 Safari 中启用 JavaScript 错误/调试控制台?如果是这样,我们将不胜感激。
采纳答案by andynormancx
A quick Google turns up this blog post(posted after you asked your question), that should at least let you see any Javascript errors via the Android Debug Bridge using the command:
一个快速的谷歌打开了这篇博文(在你提出问题后发布),它至少应该让你使用以下命令通过 Android 调试桥看到任何 Javascript 错误:
adb logcat WebCore:V *:S
Not quite the same as a full debug console though.
虽然与完整的调试控制台不太一样。
回答by thrusty
It looks like, with the Android 2.0.1 SDK you'll need to filter on "browser" instead of "WebCore"
看起来,使用 Android 2.0.1 SDK,您需要过滤“浏览器”而不是“WebCore”
回答by Nir
On Android write about:debug on the address line when the current page is the page you want to debug. you will get access to the console.
在 Android 上,当当前页面是您要调试的页面时,在地址行上写 about:debug。您将可以访问控制台。
回答by Matt Zukowski
I know your question is about Safari, but you might want to look into using Chrome instead. You can now use Chrome's desktop developer tools to debug and profile apps on your Android device.
我知道您的问题是关于 Safari,但您可能想考虑使用 Chrome。您现在可以使用 Chrome 的桌面开发人员工具在您的 Android 设备上调试和分析应用程序。
Here's how:
就是这样:
- On AndroidChrome, go to settings -> Developer tools and check "Enable USB Web debugging"
- On the desktop, run
adb forward tcp:9222 localabstract:chrome_devtools_remote
- Now on DesktopChrome, navigate to localhost:9222.
- 在AndroidChrome 上,转到设置 -> 开发人员工具并选中“启用 USB Web 调试”
- 在桌面上运行
adb forward tcp:9222 localabstract:chrome_devtools_remote
- 现在在桌面Chrome 上,导航到 localhost:9222。
You should see a list of the pages you have open on your phone. Click the one you want to debug/profile.
您应该会看到您在手机上打开的页面列表。单击要调试/配置文件的那个。
Detailed instructions are here
详细说明在这里
回答by Rory
回答by xverges
You can view the log and much more with weinre
您可以使用 weinre 查看日志等
From the Weinre docs
weinre is a debugger for web pages, like FireBug (for FireFox) and Web Inspector (for WebKit-based browsers), except it's designed to work remotely, and in particular, to allow you debug web pages on a mobile device such as a phone.
weinre 是一个网页调试器,比如 FireBug(针对 FireFox)和 Web Inspector(针对基于 WebKit 的浏览器),除了它是为远程工作而设计的,特别是允许您在手机等移动设备上调试网页.