I'm developing a website for mobile. It works on Firefox desktop. It works on iPhone, but when I press a buton on Android 2.x (and maybe lower). my JavaScript code crashes or what else...
Can I get access to the logger or JavaScript console for those devices?
The better should be a kind of Firebug application.
This question is related to
javascript
android
html
mobile
android-browser
I also looked for a simple console replacement, just to dump text. So what I did was this function:
function remoteLog (arg) {
var file = '/files/remoteLog.php';
$.post(file, {text: arg});
}
The remote PHP file recorded all the output to a database in arg
. It took me 5 minutes (OK, on the server side I used a simple logging library that records and displays text messages, but still...).
I had the same problem, just use console.log(...)
(like firebug), and the install a log viewer application, this will allow you to view all the logs for your browser.
You can type about:debug
in some of the mobile browsers to pull up a JavaScript console.
If you're using Cordova 3.3 or higher and your device is running Android 4.4 or higher you can use 'Remote Debugging on Android with Chrome'. Full instructions are here:
https://developer.chrome.com/devtools/docs/remote-debugging
In summary:
Or, if you're using Cordova 3.3+ and don't have a physical device with 4.4, you can use an emulator that uses Android 4.4+ to run the application through the emulator, on your desktop computer.
We are following the below steps in our project for debugging a website on mobile.
If you don't mind forwarding through a 3rd party server, JSConsole is a rather useful remote debugger for JavaScript.
You can try YConsole a js embedded console. It is lightweight and simple to use.
How to use :
<script type="text/javascript" src="js/YConsole-compiled.js"></script>
<script type="text/javascript" >YConsole.show();</script>
I have recently written a tool for showing console logs in a movable/resizable "window" (actually a div). It provides similar functionality to Firebug's console but you can see it over your page on a tablet. Tablet/Smartphone/Phablet Debug Console
I installed console add-on of the firefox (https://addons.mozilla.org/en-US/android/addon/console/) on my firefox browser on android and it worked quite well. Helped me debug my angular2 app.
On 2013-12-03 Google launched Chrome DevTools for Mobile, which lets developers remote debug mobile web applications via emulation and screen-casting with Zero Configuration.
For all features, checkout Paul Irish's talk on YouTube.
Chrome has a very nice feature called 'USB Web debugging' which allows to see the mobile device's debug console on your PC when connected via USB.
EDIT: Seems that the ADB is not supported on Windows 8, but this link seems to provide a solution:
http://mikemurko.com/general/chrome-remote-debugging-nexus-7-on-windows-8/
"USB Web debugging" is one option
"printing it on the screen" another.
But I prefer remote debugging through 'adobe edge inspect' formally known as adobe shadow. It uses weinre internally (=WEb INspect REmote)
You just install it + a small plugin in the browser (Chrome) and a free app you can download in the play-store. Then you have all the tools like the Chrome Development tools.
It has also support for iOS and Kindle Fire
Update
Like Chris noticed, you have to pay a subscription to use edge inspect. A cheap alternative is to use weinre directly, it's the base of edge inspect. Here's an article about how to set it up.
I sometimes print debugging output to the browser window. Using jQuery, you could send output messages to a display area on your page:
<div id='display'></div>
$('#display').text('array length: ' + myArray.length);
Or if you want to watch JavaScript variables without adding a display area to your page:
function debug(txt) {
$('body').append("<div style='width:300px;background:orange;padding:3px;font-size:13px'>" + txt + "</div>");
}
MobileConsole can be embedded within any page for debugging. It will catch errors and behave exactly as the native JavaScript console in the browser. It also outputs all the logs you've written via an API of window.console.
Source: Stackoverflow.com