Remote JavaScript debugging on Android remote JS debugging

Source: Internet
Author: User

When debugging a webpage on an Android mobile device, developers may unconsciously fall into the quarary of debugging. The android Development Guide provides a solution that is complicated and complicated. Therefore, many web developers tend to use firebug similar to Firefox.
Or tools such as WebKit Web Inspector for debugging, because they are indeed easy to use and powerful. However, even if developers use these tools, another problem is that the debugging result is completely different from that displayed on the final device. In this regard, we decided to create a set of our own solutions-A Tool derived from the standard solution proposed by the android team-which is actually much simpler. We call it "remotejs". remotejs allows you to debug JavaScript code that actually runs on Android devices, or a simulator that runs on your workstation.

Developers often run into Debugging hurdles when testing web pages for Android mobile devices. and, while the Android Developers Guide provides a solution, it's a bit cumbersome and complex. so, parse web developers often turn to tools like Firefox's firebug
Or WebKit's Web Inspector because they are easy to use, powerful, and convenient. however, what developers often find when using these tools is that the end result is quite different on the actual device. we decided to create our own solution-a tool based
On the standard solution proposed by the android team, but much simpler to use. we call it remotejs, a tool that enables you to debug your JavaScript code while running on an Android device or emulator from your workstation.

Build remotejs

Building a remotejs program is a straightforward process. First, make sure that you have installed the QT framework. Then, download remotejs from the new "android tool" in the sencha lab source code library.
Source code. Build a desktop application as follows:

Building the application is a fairly straight forward process. First, confirm that you haveqt framework installed. Then, download the remotejs
Source code from our brand new Android tools repository on sencha labs. Build the desktop application as follows:

[Plain]View
Plaincopy

  1. Git clone git: // github.com/senchalabs/android-tools.git
  2. CD Android-tools/remotejs/src/desktop
  3. Qmake & make

Next, you need to install the android SDK and connect the device to the computer (or start your simulator ). The following is a remotejs tool next to the simulator, used to detect
Touch example:

Next, all you need to do is install the android SDK, plug your device in (or launch your emulator), and you're ready to go. Here's a screenshot
The remotejs tool running next to an emulator, inspecting anexample from sencha touch:

The program automatically installs a package with the same name as the package name on the device. This tool is actually used to replace the webpage loader of the android browser. Since both programs use the same web browser engine, from the programmer's perspective, there is no need to worry about consistency. The two applications are exactly the same. For more information, see the readme. Enter
URL to open the URL. If you enter a protocol that does not start with "www" by default. If you connect to more than one device, you will make a selection in a list. Similarly, when you disconnect a device, it detects this event and then drops back to the only connected device. Then wait until you connect to the next device again. Note that you need to use console. log to output some content.

The program automatically installa package with the same name on the device. this tool will be actually be the one loading your page, instead of the android browser. this doesn't represent any concern from the developer's perspective, since the web engine
Component that is used is exactly the same on both applications. For further details on how it works and the implementation details, please refer to thereadme.
To open a specific URL, just enter it on the console. if you don't include the Protocol, only addresses starting with "www" will be validated. if you have more than one attached device, you'll be presented with a list to choose from. similarly, it will
Detect when you disconnect the device already being used. it will then fall back to the only attached device left, if that's the case, or wait until you connect one again. please note that in order to actually get some output back, you need to make use of console. log.

Compile the script Scriptable remote debugging for remote debugging

We think that since the GUI version works so well, we can write something similar and seamless. The main goal is to make full use of the language automation page regression testing that has been selected in Python. Therefore, write an android
The Python module of DEBUG bridge (Android debug bridgeadb) allows you to write scripts flexibly from your host. Naturally, a remotejs shell version is also written on the top of the ADB module. It listens to the Javascript commands entered by stdin and then outputs the results to stdout. Here is an example to debug another sencha.
Touch example:

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, anandroid
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:

Future coming up

The source code is constantly changing. We plan to inject more functions into these tools. You are welcome to contribute in any way. In the ADB Python module, events recorded on the device may be remotely automatically injected and can be performed at any time. This will make linear automatic check consistency possible. So stay tuned and clone the android toolkit on our public library and try it yourself. All available
MIT license.

The source code is changing constantly, and we plan to extend the capabilities of these tools. you're more than welcome to contribute in any way. with the ADB Python module, it will be possible to remotely automate the injection of recorded events on the device
And grab screenshots at any point. this will allow automatic verification of behavior consistency along time. stay tuned and please feel free to clone our Android-tools public repository to play around with the tools and code. all is available under
MIT license.

References: http://blog.csdn.net/zhangxin09/article/details/7069583

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.