Wednesday 3 February 2010

Androing Emulator: Is the slow launch time killing the buzz for you?

In a typical Android application development session one would have the need to iteratively make changes, launch emulator, deploy, test and debug his/her application. And if you are in the habit of nuking the emulator between iterations, you could be in a very frustrating and "pull your hair out" type of experience.

The launch of an emulator session is pretty expensive process and one shouldn't need to incur this penalty unless absolutely necessary. When an emulator comes to life it is available for debugger connections on a well known port. Upon being asked to run an application, Eclipse probes for an emulator and if found connects to it (via the aforementioned port), else it starts a new emulator. The conditional launch saves a lot of development time.

To drive home the point, below are logs of activities that happen between when an user clicks on the "run" button in Eclipse and the application is available for use. The idea is to avoid the "Reds" and stay in the "Green".

Initial run

Since the eclipse cannot find an emulator, it starts one and uses it.

  1. [2010-01-25 05:50:15 - HelloWorld]------------------------------
  2. [2010-01-25 05:50:15 - HelloWorld]Android Launch!
  3. [2010-01-25 05:50:15 - HelloWorld]adb is running normally.
  4. [2010-01-25 05:50:15 - HelloWorld]Performing keepItSimple.android.gwa.Practice activity launch
  5. [2010-01-25 05:50:15 - HelloWorld]Automatic Target Mode: launching new emulator with compatible AVD 'TestVirtualDevice201'
  6. [2010-01-25 05:50:15 - HelloWorld]Launching a new emulator with Virtual Device 'TestVirtualDevice201'
  7. [2010-01-25 05:50:46 - HelloWorld]New emulator found: emulator-5554
  8. [2010-01-25 05:50:46 - HelloWorld]Waiting for HOME ('android.process.acore') to be launched...
  9. [2010-01-25 05:52:50 - HelloWorld]HOME is up on device 'emulator-5554'
  10. [>[2010-01-25 05:52:50 - HelloWorld]Uploading HelloWorld.apk onto device 'emulator-5554'
  11. [2010-01-25 05:52:51 - HelloWorld]Installing HelloWorld.apk...
  12. [2010-01-25 05:53:28 - HelloWorld]Success!
  13. [2010-01-25 05:53:28 - HelloWorld]Starting activity keepItSimple.android.gwa.Practice on device
  14. [2010-01-25 05:53:43 - HelloWorld]ActivityManager: Starting: Intent { cmp=keepItSimple.android.gwa/.Practice }
Second run, after closing the emulator

Since, we closed the emulator from the previous session, Eclipse has no choice but to launch a new instance. Now is a good time to "pull you hair".

  1. [2010-01-25 05:54:06 - HelloWorld]------------------------------
  2. [2010-01-25 05:54:06 - HelloWorld]Android Launch!
  3. [2010-01-25 05:54:06 - HelloWorld]adb is running normally.
  4. [2010-01-25 05:54:06 - HelloWorld]Performing keepItSimple.android.gwa.Practice activity launch
  5. [2010-01-25 05:54:07 - HelloWorld]Automatic Target Mode: launching new emulator with compatible AVD 'TestVirtualDevice201'
  6. [2010-01-25 05:54:07 - HelloWorld]Launching a new emulator with Virtual Device 'TestVirtualDevice201'
  7. [2010-01-25 05:54:35 - HelloWorld]New emulator found: emulator-5554
  8. [2010-01-25 05:54:35 - HelloWorld]Waiting for HOME ('android.process.acore') to be launched...
  9. [2010-01-25 05:56:08 - HelloWorld]HOME is up on device 'emulator-5554'
  10. [2010-01-25 05:56:08 - HelloWorld]Uploading HelloWorld.apk onto device 'emulator-5554'
  11. [2010-01-25 05:56:08 - HelloWorld]Installing HelloWorld.apk...
  12. [2010-01-25 05:56:39 - HelloWorld]Success!
  13. [2010-01-25 05:56:39 - HelloWorld]Starting activity keepItSimple.android.gwa.Practice on device
  14. [2010-01-25 05:56:52 - HelloWorld]ActivityManager: Starting: Intent { cmp=keepItSimple.android.gwa/.Practice }
Thrid run, deploy to an existing emulator instance

Now we a bit smarter and deployed our application onto an existing emulator instance. Life is better once again

  1. [2010-01-25 05:57:11 - HelloWorld]------------------------------
  2. [2010-01-25 05:58:16 - HelloWorld]Android Launch!
  3. [2010-01-25 05:58:16 - HelloWorld]adb is running normally.
  4. [>[2010-01-25 05:58:16 - HelloWorld]Performing keepItSimple.android.gwa.Practice activity launch
  5. [2010-01-25 05:58:16 - HelloWorld]Automatic Target Mode: using existing emulator 'emulator-5554' running compatible AVD 'TestVirtualDevice201'
  6. [2010-01-25 05:58:16 - HelloWorld]Uploading HelloWorld.apk onto device 'emulator-5554'
  7. [2010-01-25 05:58:16 - HelloWorld]Installing HelloWorld.apk...
  8. [2010-01-25 05:58:23 - HelloWorld]Success!
  9. [>[2010-01-25 05:58:23 - HelloWorld]Starting activity keepItSimple.android.gwa.Practice on device
  10. [2010-01-25 05:58:29 - HelloWorld]ActivityManager: Starting: Intent { cmp=keepItSimple.android.gwa/.Practice }
Now, stay away from the close button.

No comments:

Post a Comment

Blog Archive

Followers