Mar 14, 2013

Android Emulator Using QEMU-KVM

I am assembling the scattered notes and solutions for running Android Emulator using QEMU-KVM. Here is the official from Android Developer Website.

First install the QEMU-KVM on your system properly. I am using Ubuntu.

Noticed the parameter to add before running the emulator:

-qemu -m 512 -enable-kvm

For me the emulator just won't show, or randomly does, or start slow. Then I add -clock ? parameter to choose timer alarm method. Now the emulator shows up immediately.

First find out what timer alarm method to choose with:

$ qemu-system-x86_64 -clock ?

You'll get something like:

Available alarm timers, in order of precedence:

I choose dynticks so the parameter for running the emulator is now:

-qemu -clock dynticks -m 512 -enable-kvm

To start the emulator scaled, add the scale ratio:

-scale 0.57 -qemu -clock dynticks -m 512 -enable-kvm

Noticed that the emulator still boots slow. But at the rate of the real device. To save time you can tick the Snapshot option for the emulator image. You can't use GPU support if you do that, you have to choose either one.

Add the -snapshot parameter using default-boot as value.

-snapshot default-boot

About the GPU support, if ran into warning messages about openGL, use the libs in the emulator binary folder. Insert before the rest of the LD_LIBRARY_PATH environment variable. Use it like this:

env LD_LIBRARY_PATH="$HOME/opt/adt-bundle-linux-x86_64/sdk/tools/lib:$LD_LIBRARY_PATH" $HOME/opt/adt-bundle-linux-x86_64/sdk/tools/emulator64-x86 -avd Tab_7_Snapshot -netspeed full -netdelay none -scale 0.57 -snapshot default-boot -qemu -clock dynticks -m 512 -enable-kvm

I am getting garbage message nativeGetEnabledTags. To clear it from Logcat, I use this message filter:


... and put it in Saved Filter.

If you have sounds from the emulator but looses sounds from your desktop, it's because QEMU takes over all alsa, not going through dmix. Add these to your environment variables:


You can put those in /etc/profile.d/ or you can just add it when running the emulator from command line.

That's it! :-)

Edit 5/9/2015:

This is how I start the emulator now. AVD named "high" using Android 5.1.1 x86, and ANDROID_SDK_ROOT set to SDK path. Remember to add  "$ANDROID_SDK_ROOT/tools" to PATH. Don't set LD_LIBRARY_PATH in .bashrc, you only want the library for simulator. It's on Intel Celeron with vt-d:

env LD_LIBRARY_PATH="$ANDROID_SDK_ROOT/tools/lib64:$LD_LIBRARY_PATH" emulator -avd high -scale 0.51

Edit 6/20/2015:

For running on Mac, follow the instructions at Android Developer. Run the .dmg file mentioned there for Mac.

Cordova WebSQL Path

The SQLite database file for Cordova WebSQL resides in: /data/data/<>/app_webview/databases/file__0/1