Perform the following steps:
1. Connect your mobile phone to your computer through a data cable
2. Set the Android phone to USB debugging mode. Step: Choose menu> Settings> Application> development and select USB debugging]
3. If Windows is used, the system will prompt you to install the driver:
Select the correct android SDK installation directory and click Next. The system will start to install the driver.
4. After the driver is installed, restart the computer (the system usually prompts "install a new driver and restart it to take effect ").
5. Repeat steps 1st and 2nd to open the command window and check whether the mobile phone device has been identified, as shown below:
"Ht99ylg11834 device" is the detected mobile phone device.
6. Next, debug the android program on Eclipse. Right-click the android project and choose run as> Android Application. The following window is displayed: (this effect can be achieved after the system is restarted)
7. Select the mobile phone device, click OK, and the program will start to be installed on the real machine. The console outputs the following information:
[22:24:49-helloworld] uploading helloworld.apk onto device 'ht99ylg11834 ′
[22:24:49-helloworld] installing helloworld.apk...
[22:24:53-helloworld] success!
[22:24:53-helloworld] Starting activity com. eightqiu. activity. statsresultactivity on Device
[22:24:57-helloworld] activitymanager: Starting: intent {act = android. intent. action. main cat = [android. intent. category. launcher] CMP = com. eightqiu. activity /. statsresultactivity}
8. Set the application to debug mode. Operation: Edit androidmanifest. XML to add the debugging parameter Android: debuggable = "true", as shown below:
<Application Android: icon = "@ drawable/icon" Android: Label = "@ string/app_name" Android: debuggable = "true">
9. Execute the real machine debugging operation: In the eclipse debugging dialog box, select manual in the target window, click the debug button, and select the real machine device to start debugging.
Note: whether or not the eclipse environment is enabled, any Android software can view the exception information in the command line window as long as an exception occurs on the real machine:
Run:./ADB logcat to view more system exception messages. In these messages, check the caused by: header line, which specifies the line of code error
10. Run this application so that you can use your mobile phone to test it.