Monday, February 13, 2012

Test and Debug

After writing your codes, it's time to test my application.

Using Android Virtual Emulator
One way to test your application is to run it on a virtual device.  The Android Virtual Device is included in the Android SDK tools.

1. Run the AVD manager.
On Eclipse, click Windows > Android SDK and AVD Manager.

2. Create a new virtual device.
- Name: virtual_galaxyS
- Target: Android 2.2
- SD card size: 512MiB
- Skin: Built-in: HVGA

* You can create several AVD with different screen sizes and Target versions.

3. Run your application.
On Eclipse, click Run > Run

* If you have multiple AVD, choose one that you want to use.

Now, have you made a good, working app already? Then good for you but most of the cases, it's not. So we need to debug.

Debugging

In debugging, the DDMS and DEBUG perspective view in the Eclipse IDE are  helpful.


The Debug Perspective in
Eclipse gives you access to the following tabs:
  • Debug - Displays previously and currently debugged Android applications and its currently running threads
  • Variables - When breakpoints are set, displays variable values during code execution
  • Breakpoints - Displays a list of the set breakpoints in your application code
  • LogCat - Allows you to view system log messages in real time. The LogCat tab is also available in the DDMS perspective.
The DDMS Perspective in Eclipse lets you access all of the features of DDMS from within the Eclipse IDE. The following sections of DDMS are available to you:
  • Devices - Shows the list of devices and AVDs that are connected to ADB.
  • Emulator Control - Lets you carry out device functions.
  • LogCat - Lets you view system log messages in real time.
  • Threads - Shows currently running threads within a VM.
  • Heap - Shows heap usage for a VM.
  • Allocation Tracker - Shows the memory allocation of objects.
  • File Explorer - Lets you explore the device's file system.

If you have already successfully made your app working on the AVD, you may want to try it on the actual device. Be sure not to miss this part. It is important to see how your app works on the actual device.

Using your actual device to test your app.
In this case, Samsung Galaxy S with Android v2.3.3

1. Connect your phone to your PC via USB.
- Be sure to set your phone to 'Debug mode when connected to USB.'

2. Run your app.
- On Eclipse, click Run > Run.

3. Choose your device.
- Select your phone and not the AVD.


You can now try your application on an actual device.


Sometimes, it is not possible to try your applications on the AVD because of unsupported features. For  example, you cannot test your app using the bluetooth function on an AVD so you can test to your own device right away. 

1 comment:

  1. Really nice post. Very important topic you have selected to share with us. It is useful. Keep sharing. Thanks a lot.

    iPhone App Development | Android Apps Development

    ReplyDelete