Remote JavaScript debugging on Android

Source: Internet
Author: User

Developers often encounter many obstacles when debugging webpages on Android mobile devices. although the android Development Guide provides a solution, this solution is very complicated and troublesome. therefore, many web developers often Debug on Firefox debug or WebKit's Web Inspector, because these tools are powerful and easy to use. however, developers often find that the effects of these tools are far different from those seen on mobile devices.

We decided to build our own solution, and set up a more easy-to-use tool in the standard solution proposed by the adndroid team. We call it remotejs, which makes yourProgramDebug your JavaScript locally while running in Android devices or SimulatorsCode.
How to Create remotejs
Building an application is a simple process. first, confirm that you have installed the QT framework. then download the remotejs source code for Android from our sencha libs. to build a desktop application:

View Source

Print?1.Git clone <a href ="Git: // github.com/senchalabs/android-tools.git"> Git: // github.com/senchalabs/android-tools.git <;/A>2.CD Android-tools/remotejs/src/desktop3.Qmake & make

Next, you need to prepare the installed Android SDK and insert your Android device (or start your simulator ). Here is the remotejs tool. An example of a sencha touch running on the simulator:

The program automatically installs a package with the same name on the device. use this tool to open your webpage, instead of the browser that comes with Android. however, because the two programs use the same web engine components, you do not have to worry about compatibility issues. The results of the two programs will be exactly the same. for more information, see the instructions.

To open a specified URL, you only need to enter it on the console. If the URL you entered does not contain a protocol (for example, HTTP), only addresses starting with "www" will be identified. If you connect to multiple devices, you will get a list for selection. Similarly, it checks whether your current settings are disconnected. Then it only leaves the connected device. Similarly, if a device is newly added, it will also be detected.

Note that you need to use console. log to get some actual output.

Compile a remote debugging script
We thought that since the GUI version worked so well, we cocould write something similar that wocould run headlessly. the main goal was to automate page regression tests, taking full advantage of Python, the chosen implementation language. for that, an android debug bridge (ADB) Python module was written, which allows for very flexible scripting from your host. naturally, a shell version of remotejs was also written on top of the ADB module. it listens for Javascript commands on stdin and output results to stdout. here's the tool in action, debugging another sencha touch example:

Coming soon
Source codeIs constantly changing. We plan to extend the functions of these tools. You are welcome to contribute to the above functions in any way. Please continue to pay attention to the tools and code in our Android-Tools resource library. All these are released with the MIT license.

Original English:
Http://www.sencha.com/blog/2010/11/05/remote-javascript-debugging-on-android/

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.