Have you ever thought of running Android applications on your Linux system? Well, that’s what we will show you in this article.
If you have used the Windows operating system or macOS, you must have encountered Bluestacks or Nox, which allows you to run Android applications on your PC.
Unfortunately, they don’t have any releases for Linux platforms – that’s where Anbox comes into play.
What’s Anbox (“Android in a Box”)?
In simple terms, Anbox is an Android emulator. It is like the Bluestacks/Nox version for Linux systems.
Anbox is a free and open-source compatibility layer Linux system emulation tool that allows users to run mobile games and other Android applications on their Linux machine. Different reasons might influence one to run their mobile apps on the PC.
For example, mobile games are getting more sophisticated nowadays, and the small mobile screen doesn’t seem wide enough to give a user the ultimate experience they might need.
Additionally, it can get quite tiresome using some applications on the mobile phone compared to the PC, which comes with a wide monitor and an easy-to-access keyboard.
Anbox uses LXC (Linux Containers) to run the Android runtime environment. It recreates the Android directory structure as a mountable loop image and executes applications using the native Linux kernel.
For isolation, it takes advantage of Linux namespaces via LXC. All accesses are routed through the Anbox daemon. That is also a security measure as applications don’t have any direct access to the hardware resources.
How is Anbox Different from Shashlik and Genymotion?
To run the Android environment on Linux systems, Shashlik and Genymotion utilize an emulator. That is quite different from what Anbox does.
Anbox runs the Android system under the same kernel as the host operating system, whereas the emulator generates a whole emulated system with its own kernel. There is no need for an emulation layer like QEMU. The hardware handles everything. This method also provides a much better interface with the host OS.
To install and run Anbox on your system, follow the steps below.
Step 1. Load Kernel Modules
We need to load two main modules on our system to run Anbox successfully.
If you have enabled SecureBoot, execute the command below to sign the kernel module.
sudo kmodsign sha512 /var/lib/shim-signed/mok/MOK.priv /var/lib/shim-signed/mok/MOK.der /lib/modules/
To check whether you have enabled secure boot, run the command below on your Terminal.
sudo apt install mokutil sudo mokutil --sb-state
If you get an error like “EFI variables are not supported on this system,” you are probably running on Legacy instead of UEFI.
To load the stated kernel modules, use the commands below.
sudo modprobe ashmem_linux sudo modprobe binder_linux
To verify whether the modules were successfully loaded, run the grep command below.
lsmod | grep -e ashmem_linux -e binder_linux
Step 2. Install Anbox
Anbox can run several Linux distributions as it is available as a Snap package (a distribution independent package manager). Be sure to check out our post “Differences Between Snap, AppImage, and Flatpak” to better understand these three popular package managers.
Therefore, Anbox can run on any Linux distribution that supports Snap packages. Examples of these distros include:
- Arch Linux
- Linux Mint
To get started, install the
snapd daemon on your system with the command below.
sudo apt install snapd
When done, confirm snapd was successfully installed on your system, execute any of the commands below.
snap -version snap find hello
The latter will list several hello packages.
Now, execute the command below to install Anbox on your system.
sudo snap install --devmode --beta anbox
This might take a while depending on your internet speed. Please be patient. After a successful installation, restart your PC.
sudo reboot now
You can now proceed to launch Anbox from the Applications menu. You will see several default applications like Calculator, Calendar, Clock, etc.
Tip: If Anbox can’t launch and you are stuck on the “Starting …” screen, wait for this screen to disappear (or you can close it manually) then launch Anbox again. That is a known bug in Ubuntu but it shouldn’t affect the latest releases of Ubuntu.
Step 3. Install Applications on Anbox
Like any other Android phone, there are two main ways in which you can install applications on Anbox.
- Sideloading apps
- Install apps from the Google play store.
Sideloading is a term used to refer to installing applications on your phone using the apk file. This is one of the best methods which you can use to install applications that are not yet in the play store or even install an app that you are developing and haven’t pushed to the play store.
Before getting started with sideloading, we first need to allow Anbox to install applications from unknown sources. Follow the steps below.
- Open the Settings app from the Anbox main window.
- Scroll down and click on Security
- On the new screen that appears, scroll down and toggle the button next to Unknown sources to allow installing apk files on Anbox.
When done, you can now launch the browser and download any apk files you want to install on Anbox. For this post, we will install Quickpic.
Once you have the apk downloaded on your PC, launch the Terminal and follow the steps below to install the app.
- Install android-tools-adb on your system.
sudo apt install android-tools-adb
- Start the Anbox container
- When done, proceed to install the application using the syntax below.
adb install [path_to_apk]
adb install QuickPic.apk
Failure [INSTALL_FAILED_NO_MATCHING_ABIS: Failed to extract native libraries, res=-113]then there is a high probability the application you are tryin to install is developed for ARM architecture and not x86_64.
If the installation was successful, you should see the message Success on the Terminal and also be able to launch the app on the Anbox window.
Install Apps from Google Playstore
This is the official and recommended method of installing applications on Anbox and even your mobile phone. That’s because hackers might have modified most APKs that you download online to run malicious code on your system.
To get started, we first need to install Google Playstore on Anbox. There are many ways to do this, but the easiest is using the Anbox Playstore Installer. Launch the Terminal and follow the steps below.
- Install the necessary packages required to run the installation script on your system.
sudo apt install wget curl lzip tar unzip squashfs-tools
- Clone the Anbox Playstore Installer script on your system using the command below.
- Make the script executable using the
chmod +x install-playstore.sh
- Run the script with the command below.
After a successful install, you should be able to see the Google Play Store on the Anbox window.
Launch the Settings app and set the required permissions for the Google play store to finalize. Follow the steps below.
- Launch the Settings app from the Anbox window
- Scroll down and click on Apps -> Google Play Services.
- Select Permissions and enable the permissions you want
- Repeat this process for the Google Play application.
That’s it! You can now proceed to install the application from the Play store.
Up to this point, we believe you can now comfortably install and run Android applications on your Linux system with Anbox. Even though Anbox is one of the most reliable applications for running Android apps on Linux, it’s not the only one. We have other applications like
- Android Studio
Additionally; there are Android-based operating systems that you can install on your x86_64 PC allowing you to install and run Android applications natively. These include
Have a good time running Anbox on your system, and don’t hesitate to hit the comments section if you come across any errors.