Android DDMS

DDMS can be used to analyze a running application for all run-time details such as memory consumption, process calls, and so on.

The main functions of Android DDMS are port providing, screen capture on a device, thread details, heap details, and Logcat processing. This service can be used for spoofing calls and messaging.

Android DDMS is widely used for device debugging. Particularly in the game development procedure, it is often used as a line-by-line debugging system. This is very useful to identify unwanted loaded objects and assets, and to track runtime exceptions:

Android DDMS

Android DDMS can be used to carry out the following activities.

Connecting an Android device filesystem

DDMS can connect to a device filesystem and provide a file browser-based operation to copy, modify, or delete any file on the device through a PC. This method or feature, however, is not very important for Android game development.

Profiling methods

Another interesting DDMS feature is profiling or tracing matrices of certain methods. It gives information on the following topics:

  • Execution time
  • Number of operations
  • Number of cells
  • Memory use during execution

Extending this feature, the developer can even gain control over profiling the data of a method by calling startMethodTracing() and stopMethodTracing().

The developer needs to keep an eye on two things:

  • Up to Android 2.1, it is mandatory to have an SD card installed on the device with the application's permission to read/write on it
  • From Android 2.2 onward, the device can stream profiling data directly to the development PC

Thread information monitoring

DDMS provides details on each thread running for each process on a selected device. However, games mostly run on a single thread. As devices are getting better each day, games are also using the multithreading feature to support various operations such as rendering, processing, file I/O, and networking.

Heap information monitoring

DDMS provides heap usage at runtime for a running process. It is very useful for game developers to track the game process heap during execution.

Tracking memory allocation

This is very useful for tracking each and every memory allocation of runtime objects. This gives every detail on each specific object of each class. This means the developer can find out which class is taking exactly how much memory. This helps achieve memory optimization in a much more efficient way.

Monitoring and managing network traffic

From Android 4.0 onwards, DDMS features a Detailed Network Usage tab to track when a game makes network requests. Using this feature, the developer can monitor network data transfer. This option can be very useful to optimize network development. It can distinguish between different traffic types by applying a "tag" to network sockets before use.

Tracking log information using Logcat

Logs are the most useful debugging technique for tracking almost anything. It is a good practice to use logs properly to check the data or value of certain objects during runtime. It is very useful for logic development for games.

In game development, logical requirements will be different for different games. So, there must be a good amount of code that is written for the first time. Predefined test cases are not available. This deficiency can be overcome using Logcat from DDMS.

Logcat provides log information in the following types:

  • Verbose
  • Debug
  • Error
  • Warning
  • Information

Emulating device operations

As we discussed Android virtual devices earlier, DDMS can work upon AVDs as well. So, it becomes much easier to emulate a real-time scenario to debug the game being developed.

The most commonly used emulations are as follows:

  • Emulating an incoming phone call
  • Emulating an incoming message
  • Emulating network state change during runtime

These three are the most common scenarios at runtime. So, these situations can be checked without a physical device. Interruption handling has been difficult for Android devices since the beginning. As a matter of fact, this can be a nightmare for a programmer if interrupts are not handled properly.

There are some common problems of crashing/freezing/restarting the game after an interrupt. Many times, some unnecessary services or processes can be interrupts, and they may change the game state during the interruption period. Emulating every possible interrupt on an AVD is always an added advantage to speed up the debugging or interrupt handling procedure.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.37.126