在Android平板电脑/手机上调试JavaScript? [英] Debugging javascript on Android tablets/phones?

查看:141
本文介绍了在Android平板电脑/手机上调试JavaScript?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在iOS上的Safari中启用调试视图?我只需要看看我正在测试一个页面的Xoom是否生成JavaScript错误。我试图找到如何在Android浏览器中启用开发工具,就像我在iOS中一样,但似乎找不到它。

How do I enable the debug view like I can in Safari on iOS? I simply need to see if a Xoom that I'm testing a page on is generating javascript errors. I was trying to find how to enable the dev tools in the Android browser like I do for iOS but can't seem to locate it.

推荐答案

我曾经在一个Android应用程序中工作,Java开发人员设置它来提醒JavaScript错误 - 引起了我们在iOS版本中没有捕获到的额外的错误。所以,如果你有访问java层,我会检查出来。我问他他特意做了什么,他说:
有一个WebView类的回调,让我知道JS代码是否引发错误,我实现了这个回调来显示一个android对话框。

I've worked on an Android app in the past where the java developer set it to alert JavaScript errors - caught an extra bug that we didn't catch in the iOS version because of it. So, if you have access to the java layer, I'd check that out. I asked him what he did specifically and he said: "There's a callback from the WebView class that lets me know when the JS code throws an error. I implemented that callback to display an android dialog."

有两个解决方案的其他想法,我用于调试(ios / android)。这些对于您无法访问内置控制台的游戏中的嵌入式网页浏览特别有用:

There's two solutions other ideas on top of this that I use for debugging (ios/android). These are especially useful for embedded web views in games where you don't have access to the built-in console:

1) Weinre 是一个仍然是beta但功能强大的远程调试器。它将在桌面上给您一个人造检查员,您可以在远程设备上查询/查看错误。有一个整体dom检查员和任何东西。发展它的人也是非常敏感的。

1) Weinre a still beta, but functional, remote debugger. It'll give you a faux inspector on your desktop that you can query / see errors on your remote device with. Has a whole dom inspector and anything. The guy that develops it is pretty responsive, too.

2)我写了一个javascript日志功能,它触发我的服务器错误日志。只是拖尾你的日志文件,你很好去。我的javascript函数看起来像这样:

2) I write a javascript log function that hits my servers error log. Just tail your log file and you're good to go. My javascript function looks something like this:

function hlog(){
    var s = Array.prototype.slice.apply(arguments).join('¶');
    document.createElement('img').src = 'http://yourdevbox/debugger/?m=' + encodeURIComponent(s);
}

我可以采取任何数量的参数。
我收到此请求的php页面如下所示:

That way I can take any number of arguments. My php page that recieves this request looks like this:

# ensure this can't be used in production 
if (strpos($GLOBALS['HTTP_HOST'], 'devboxhostname') < 0) die(':(');
error_log($_GET['m']);

希望未来,移动开发人员将有更好的调试工具。

Hopefully in the future, mobile devs will have way better debugging tools.

这篇关于在Android平板电脑/手机上调试JavaScript?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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