Trick5 – How to Emulate Android Apps on Linux – Trick5
If you’re a hardcore Android fan, you’re probably aware that your favorite mobile operating system descends from Linux. We’ve covered in the past how Android is based on open source components, and that the Linux kernel is one of those. It stands to reason then that if they’re so close, it should be relatively easy to run Android apps on Linux.
As it turns out, that’s correct. Normally running apps for one operating system on another is tricky. But there are a couple of methods available for Linux users to run Android apps that make things comparatively easy. Let’s take a look.
Exising Methods for Android on Other OSes
We’ve covered a few ways in the past to run Android or its apps on other operating systems. These typically take one of two forms:
- The first is to use a virtual machine (VM) of some sorts, sometimes called an emulator. In a nutshell, it’s software that impersonates an entire Android system. An example of this is the emulator included in Android Studio, which we used extensively when creating a simple Android app. You could also use a general-purpose VM tool like VirtualBox, and run one of the flavors of Android designed for desktop use. Finally, BlueStacks is a more optimized example of this method for Windows.
- The second method is to use compatibility software. While their precise methods vary, they are designed to translate the Android software’s input and output to something the host machine can understand. One approach uses the Chrome browser with an add-on called ARChon to achieve this effect.
In the below sections we’ll explore the following Linux-native solutions, which use the above options to varying degrees:
- Anbox, which uses Ubuntu’s Snap package format. It operates more like a compatibility layer, and launches applications from a “control panel” of sorts.
- Shashlik, which uses an optimized VM based on QEMU. It creates entries for Android apps in your regular system launcher.
- Genymotion, which uses an optimized VM based on VirtualBox. It runs a full virtual device interface.
We’ll explore each of these options below in more detail.
Anbox, as the name implies, bills itself as “Android in a box.” It’s a Linux application that provides a complete Android software stack in a container, similar to the way Docker operates. Distributed as a Snap package, your distribution will need to support that format — fortunately, most major ones do.
You can search for it in your software center, or use prompt command like the following one for Ubuntu:
sudo apt install snapd
Now that the Snap system is installed, use the command from the Anbox website to download and install it:
snap install --classic anbox-installer && anbox-installer
The terminal-based installer script will fetch everything for you. It will start by performing some admin functions like adding a new software repository and installing prerequisites. It’ll then download the Anbox Snap package (shown in the below image) and install it.
Once it’s installed, you can confirm it’s running with the following command:
Once Anbox is installed, you can launch it from your main menu. It showed up in the “Lost and Found” category for me, but it should appear with a text search. After a few moments, the “Anbox Application Manager” should pop up on the screen.
The project’s website states upfront it’s still in heavy development. You’ll feel this when it’s time to install your first app. There’s no nice graphical, drag-and-drop way to do so — you’ll need to use the Android Debug Bridge (ADB). This tool is part of Android Studio, so if it’s already installed, you’re all set. If not, you can install Android Studio (as it provides its own emulator, another option), or see if they’re available from your package manager.
On Ubuntu, the following will get you what you need:
sudo apt install android-tools-adb
Now you can install an app for which you have an APK file handy. The following command will install Orgzly, a note-taking and to-do app:
adb install com.orgzly_83.apk
Finally, you’ll see the app’s icon pop up in the Anbox window. Clicking on it will open the app just like you’d expect (the below image shows the Orgzly app we installed above):
The Esc key acts like the back button, allowing you to close the apps.
After downloading the hefty DEB package, you can install it in an Ubuntu system with the following command:
dpkg -i shashlik_0.9.3.deb
The installation of apps in Shashlik is also a work in progress. But the installation command is a little more straightfoward:
Once this completes, you’ll get a nice little popup saying it was successful.
You’ll also get an entry in the launcher menu (under the “Android Apps” category), and when you click it, the app will launch. The start-up time for Shashlik is noticably longer than Anbox, as it is actually starting up a proper VM:
Finally, your app will open in what is probably a very small window. There are some QEMU settings in */opt/shashlik/android/hardware-qemu.ini that you can tweak to get a larger screen.
Overall, the experience seems a little easier getting Shashlik installed and set up with some apps, if you’re okay with the slower start-up.
Genymotion is slightly different from the above two options.
Firstly, it’s a commercial product, so if you want to use it long-term you’ll need to pony up some cash. This also means you’ll need an account with Genymotion in order to even download the trial. Lastly, it’s positioned as a developer tool, meaning it’s not really meant as a convenient way to launch apps so much as a fully decked-out system to test with. If none of these things turn you off, you can start by filling out a simple form and registering for an account:
After logging back into your account, click the “Trial” button at the top-right of the page. It will take you to a download page where you can pick a version of Genymotion for your system. While this is downloading, you should also make sure you have VirtualBox installed, as Genymotion uses it.
Once complete, make sure you give the BIN file executable privileges, then run it as root (as shown in the command in the below image).
The simple setup will finish quickly, informing you of the available “/opt/genymobile/genymotion/genymotion” command. Running this will start the application:
The trial version will come up asking for authentication or a license. Opt to Sign In and provide your account credentials. After accepting the EULA, you’ll be asked to create a virtual device:
The app provides a selection of old and new devices. Selecting one and clicking Next twice will kick off the process, downloading and setting up the new device.
Once installed, you need only select the new device from the list in the app’s main window and click the Start button:
Once it’s running, you’ll see what appears to be a full-fledged Android device in a window.
But at first it only contains a minimal set of apps. Fortunately, with Genymotion you can use a graphical method (drag and drop) to install new ones. Dropping an APK file on the window will automatically transfer it to the virtual device, install it, and run it. In the below image we can see (again) Orgzly, this time in higher resolution:
So Which One Is Best?
The answer to this is easy: the one that runs the app(s) you need. And as is often the case, don’t think you need to select just one. If you have an app the works like a charm in Anbox, another one that hums in Shashlik, and another that requires the full horsepower of Genymotion, use them all! Feel free to throw the Android Studio emulator in there too, just for good measure!
Do you have any Android apps that you absolutely must have on your desktop? Have you used any of the above solutions? How do they compare to the likes of BlueStacks? Sound off with your thoughts and tips in the comments below!
Trick5 – How to Emulate Android Apps on Linux – Trick5