How to set up a fast emulator for Android on Linux?
This article describes how to setup a new emulator which allows to install apps which use Google Play Services.
Recently, Android 4.3 (API level 18) has been published. As former releases it contains system images for ARM and Intel Atom (x86). When creating an emulator via the Android Virtual Device Manager one can choose to target either the “plain” API level or include Google APIs. The “plain” configuration can benefit from both hardware acceleration options (ARM and Intel Atom). Running such a virtual device is quite comfortable as it behaves similar to a hardware device. The Google API targets however do not allow to use Intel Atom architecture.
This makes it highly uncomfortable to test any application which uses the Google Maps v2 API which is shipped with Google Play Services. StackOverflow has a bunch of discussion on topics around the emulator.
- Running Google Maps v2 on Android Emulator
- Google Play services out of date. Requires 3025100 but found 2012110
- This app won’t run unless you update Google Play Services. (via Bazaar)
Now, I stumbled into an alternative: the Genymotion emulator. It is based on AndroidVM, an opensource project. The emulator runs on Mac, Windows and Linux. I use VirtualBox on Ubuntu to run it. It is not too hard to set up the software:
- Download and install VirtualBox. I used the ppa:debfx/virtualbox to get the latest version.
- Sign up for a free account at the Genymotion website
- Download and install the emulator for Linux. You need to execute the genymotion-x.y.z_x64.bin file. It will extract its content and then you can run the emulator via
./genymotion/genymotion
If you happen to have problem with VirtualBox it might help to reload the kernel modules while Genymotion is running. This can be done viasudo /etc/init.d/virtualbox force-reload
as slightly different described on their website. - When the emulator has started first configure the Android SDK path
- Next download one of their images. I have chosen the one named “Galaxy S4 HTC One Xperia Z – 4.2.2 – with Google Apps – API 17 – 1080×1920”
- Run the image and enjoy the speed …
If you need to install a recent .apk you can use the Chrome extension APK Downloader Chrome Extension by Lekensteyn which simple download the .apk from Google Play Store.
Otherwise I recommend to pull them from other images of the SDK in case you do not own a rooted device. All you need is to know the correct path. The following command show how to get the .apk for Google Play Services, Google Play Store and Google Maps.
adb -d pull /data/app/com.google.android.gms-2.apk adb -d pull /data/app/com.android.vending-2.apk adb -d pull /data/app/com.google.android.apps.maps-2.apk
An alternative source is to download a Google Apps package. They are used for Android ROMs and can be found in the forum of xdadevelopers. Of course there are .apk downloads on StackOverflow but they are outdated mostly.
To install an .apk having only one emulator running run the following command (example for Google Play Services):
adb -e install com.google.android.gms-2.apk
Here are some screenshots of the running emulator:
I like to refer to the following pages for more information: