How to debug with an Android real machine

Source: Internet
Author: User
Tags configuration settings

How to debug an application using a real machine

In the development of Android applications, sometimes the development has to use the real machine debugging, the reason is very simple, because the simulator is temporarily unable to support the simulation of some hardware devices, and gravity sensing a kind of development effect more need to use real machine debugging. Of course, the use of real-machine debugging is much faster than the simulator, the simulator not only the resources of the PC, but also run for a long time will become quite slow.

Android Real-Time debugging is the most need to solve the problem is the real machine and computer connection, once the successful connection, in fact, with the simulator debugging is no different, just want to run Android project when the real machine can be selected. Before Android2.3, because Android genuine machine does not have the unified standard, the model is numerous and the respective USB drive is different, therefore needs to go to the respective handset manufacturer official website to download and installs corresponds the correct USB driver (or the ADB Interface Driver) , but in the new version of the SDK, Google provides a new USB drive solution, which is stored in the "%android_sdk_path%/google-usb_driver" folder, Generally speaking, the popular Android models are supported, thus simplifying the installation of USB drivers, we prefer this driver to install, it is impossible to successfully install and then download the driver provided by the real machine manufacturer. Here is an example of the motorolamilestone used by the author in Win7.

The first step: Open the USB debugging function of the android real machine we are developing (open method for settings (set) àapplications (application) àdevelopment (development) à tick USB debugging (USB debug)), The USB cable is then connected to the PC used for development, and because it is connected without a USB drive installed, the system discovers new hardware and tries to install it on the Internet by searching for drivers via Windows Update:

The second step: because it takes a long time to find the driver through Windows Update and requires Internet support and does not necessarily succeed, we click the "Skip from Windows Update for driver Software" button below to skip the search:

Step three: After the automatic installation, by right-clicking on "Computer" (xp-My Computer) select "Manage" to enter the Computer Management interface, click on the left "Device Manager" to enter the device management interface, we will find a yellow exclamation mark of the hardware device (shown in the other Device branch), That is "Motorola ADB Interface", which represents the lack of driver support for the device, it is obvious from the name that this device is the support device we need for USB debugging:

Fourth Step: Install the device driver, right click on "Motorola ADB Interface" Select "Update Driver software", pop up as shown in the box body:

Fifth step: As mentioned earlier, because the USB driver is already available in our SDK, we chose the second item "Browse the computer to find driver software", go to the next dialog, click here to browse, select the directory "%android_sdk_path%/ Google-usb_driver ", for example, here is the D:\study\programfiles\android-sdk-windows-r8\google-usb_driver path used, tick" include subfolders "below Click Next:

Sixth step: After the last step to click the Next button, the system will start to find the driver software in the folder we set up and install, this step takes about 2 minutes, please wait patiently:

Seventh step: Wait a period of time, no accident, the system will prompt "has successfully updated the driver software", such as, if this step failed, do not panic, it may be provided by Google this driver temporarily does not support the real machine you use, Then you need to go to the manufacturer of the machine you use the official website to download the driver software, and then repeat the previous steps, only need to set the driver software path in the fifth step when you navigate to the location of the specific driver of your new download, the attachment also provides two common USB drivers, That is, Motorola and HTC USB drive.

Eighth step: After the driver installation is complete, and then to the Device Manager, you can find the "Motorola ADB Interface" device with the yellow exclamation point is gone and replaced by the Android phone branch "Android Composite ADB Interface "Device, here again, if you are using the Motorola driver, here is probably the" Motorola ADB Interface "displayed:

Nineth Step: Although the previous system has prompted the driver installation is correct, if you can determine that the PC has been identified

Android Real Machine and set up the connection correctly? Very simple, first click Start-to-run, enter CMD:

Tenth step: Use commands in the popup command prompt interface to view the device (the ADB command corresponds to the application stored under the%android-sdk-path%\platform-tools path, devices This can be used in any path under the ADB because the author of the environment variables added to the path, if not set the environment variables need to first locate the%android-sdk-path%\platform-tools path, otherwise it will prompt adb is not a valid command, As shown, a device with number 04038b6005021006 is returned, which means that the real machine has been successfully connected to the PC, and if the emulator is also running on the PC, more than one record will be found, the type of simulator is emulator:

So, how to choose the Real machine when debugging? Typically, when we click to run an Android project, its default behavior is that eclipse chooses a device to install and run the application, and if you want to manually select the debug device, you can Configuration settings,

After clicking on the run configuration, the Config interface will be displayed:

The field on the left side of the interface is a configurable application that exists now, select the application to be debugged on the left, then click on the Target tab on the right, select Manual (Manual), and be aware that It seems that there is a small problem with eclipse here (which may be the author's own operational problem), that is, a new project before the first compilation runs, the project's corresponding application will not appear in the list of applications on the left, so it cannot be set. This means that the target device can only be specified by eclipse using automatic in the first run. However, this does not make much difference, and if eclipse launches a simulator at this point, it can immediately close the emulator and terminate the operation, and then the project application will appear in the list to be configured as manual:

After configuring the manual mode, a selection box will pop up when you run an Android project to select the device, as follows:

You can see that our real machine appears in the list of running devices, click OK or simply double-click it to install the application to the real machine for debugging, of course, if you need to debug the simulator, select "Launch a new Android Virtual Device" Then select the emulator that needs to be started (the emulator is already established in the list, or you can create a new emulator).

Citation: Http://wenku.baidu.com/link?url=RxOBMJWhKafHVHA5XjWE1m7v_obLRfoAGe8Zw9Ck_ 8hdkb5-0u3r6fxsnsfcw34rck3jimihp4xsoefarae7v18074idyavmx3owsmy1lxk

How to debug with an Android real computer

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.