Friday, July 26, 2013

Titanium: improve Android emulator performance

Deploying to the Android emulator under Titanium can be incredibly slow. Since I'm coming from native Android app development, I know it doesn't need to be thaaaaat slow (wouldn't call it 'fast' on native java dev either).
You can speed it up though considerably if you're working on Windows by doing these 3 things:
  1. never close the emulator once it's open (easy)
  2. use Titanium's fastdev to improve deployment (read here)
  3. increase the performance of the emulator by using a Intel x86 image (see below)
Following these steps can make deploying to the emulator even faster than on the native platform.



Here's how to enable Intel x86 images on your Android emulator...

I. Install an Intel x86 image (it's not available for all Android API levels) in the Android SDK manager.


II. Download the Intel x86 Emulator Accelerator in the Android SDK manager.
You might think that's it, but this is only downloading the accelerator, not actually installing it. Running the emulator now would get you something like this:

emulator: Failed to open the HAX device!
HAX is not working and emulator runs in emulation mode
emulator: Open HAX device failed


III. Install the accelerator
You'll need to find the package that you just downloaded and execute it. It will most likely live here:
<ANDROID SDK>\extras\intel\Hardware_Accelerated_Execution_Manager


Running an emulator on the shell, you should now see something like this:


IV.  Enable an x86 image in Titanium
Now back in Titanium, go to run configurations for your project and change the Android SDK to be used to Android x.x.x [x86]:



V. Enable GPU acceleration
Open the Android Virtual Device Manager, and select edit on the emulator created by Titanium (something like titanium_23_HVGA_x86). Add a property GPU emulation and switch it to yes. (Note: this is incompatible with snapshots for whatever reasons!)


The emulator should now be super speedy!