Android Application debugging

Source: Internet
Author: User

To check what is happening in the running application, you need to check the running Dalvik VM. In eclipse, choose Window> open perspective> Other. Select ddms in the displayed dialog box. This will open a new perspective in eclipse, which has many interesting windows.

Ddms serves as a bridge between IDE and emultor (or gphone. The developer can view the running process/thread status on the target machine through ddms: the eclipse program can be connected to the development machine for running; the heap information, logcat information, and memory allocation of the process can be viewed; you can send text messages, send geographic location information, and call messages on the target machine. You can attach a process for debugging like GDB.

The following briefly introduces the resources provided in the ddms perspective:

1. Devices

All processes in emulator are listed in device. The buttons in the upper-right corner of the tab are: debug the selected process debugging process, update heap update process stack information, dump hprof file check hprof (Heap/CPU profiling tool) file, cause GC call garbage collection, update process update threads, start method profiling start method analysis, stop process stop a process, and screen capture the current screen of emulator. When you select a process and press the debug process button, if eclipse contains the code of this process, you can perform source code-level debugging. It's a bit like GDB attach. The image capture button can capture the current Android display desktop to your machine, which is also very useful.

 

The details of all the terminals connected to ddms and the app processes running on each terminal can be viewed here. the rightmost of each process corresponds to the port connected to the debugger. Because Android is developed based on the Linux kernel, it also retains the unique process ID in Linux, which is between the process name and port number.

The port used by ddms to listen to the app process on the first terminal is 8600, and the app process is allocated 8601. If there are more terminals or more app processes, and so on. Ddms receives commands from all terminals through port 8700 ("base port.

2. emulator Control

Some functions of this panel can easily enable the test terminal to simulate some interactive functions of a real mobile phone, such as answering a call and simulating various network conditions based on the options, simulate receiving SMS messages and sending virtual address coordinates to test the GPS function.

 

Telephony status: simulates the voice quality and signal connection mode with options.

Telephony actions: simulates the call and sends the SMS to the test terminal.

Location Control: simulates geographical coordinates or simulates Dynamic Route coordinate changes and displays preset geographical identifiers. You can use the following three methods:

· Manual: manually send two-dimensional latitude and longitude coordinates to the terminal.

· GPX: The GPX file is used to import the sequence to dynamically change the geographical coordinates, so as to simulate the GPS change value during traveling.

· Kml: Import unique geographical identifiers through the kml file and display them on the test terminal dynamically based on the changed geographical coordinates.

For example, enter "android Chinese" in emulator control/telephony actions, click send, and open messaging in the android simulator. The following text message is displayed:

 

3. File Manager

Displays the file system information. File explorer is very useful: it can upload files to Android, download files from Android, or delete files. The upload, download, and delete buttons are available in the upper-right corner of the tab. Generally, file explorer has the following three directories: data, sdcard, and system.

· The ram of the mobile phone corresponding to data will store temporary data such as Cache during Android OS running (/data/Dalvik-cache directory ); if you do not have root permission, the APK program is installed in/data/APP (only the APK file itself is stored);/data stores all android programs (system APK + third-party APK).

· MNT indicates mount. Mounting means that the sdcard under the MNT directory corresponds to the SD card.

· The ROM and OS of the mobile phone corresponding to system and the APK program of the system are stored here.

User applications are deployed in the/data/APP directory, while Android built-in applications are deployed in the/system/APP directory.

 

4. threads, heap, allocation Tracker

The threads view lists all threads of the current process.

The heap view displays the heap status, which is updated during garbage collection. When a VM is selected, the VM heap view cannot display data. You can click the "show heap updates" button on the right of the VM, then click "cause GC" to implement garbage collection and update the heap status.

In the allocation tracker view, we can track the memory allocation of each selected virtual machine. Click Start tracking and click get allocations.

For example, to view garbage collection information, click the [start tracking] button-> keep the program running for a period of time-> click the [get allocations] button, with the obtained allocations information, you can use the line number to accurately find out where the code is faulty.

 

5. logcat

Logcat is a log file that records activities in the VM. The application can add its own log entries through log. I (TAG, message); in this log file, the tag and message are both Java strings. The log class belongs to the Android. util. Log package.

 

6. Console

Android output information, loading program and other information.

 

Note:

During program debugging, I generally do not use logcat in DDM to view the output of information ~~, Generally, the ADB logcat command in tools in the SDK is used to call up information output.

 

 

This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/deaboway/archive/2011/02/15/6186818.aspx

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.