How To Install and Run Android Apps on Ubuntu using Anbox

android and ubuntu logos on a green gradient

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.

Even though Anbox is not the only Android emulator available for Linux systems (there are others like Shashlik and Genymotion), it comes with pretty unique features, especially performance.

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.

  • ashmem_linux
  • binder_linux

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/uname -r/kernel/drivers/staging/android/ashmem_linux.ko

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

word image 195

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
  • Debian
  • Fedora
  • Gentoo,
  • Linux Mint
  • Manjaro
  • OpenSUSE
  • Solus
  • Ubuntu

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.

word image 196

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.

word image 197

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 Applications

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.

  1. Open the Settings app from the Anbox main window.
  2. Scroll down and click on Security
  3. On the new screen that appears, scroll down and toggle the button next to Unknown sources to allow installing apk files on Anbox.word image 198

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.

  1. Install android-tools-adb on your system.
    sudo apt install android-tools-adb
  2. Start the Anbox container
    anbox.appmgr
  3. When done, proceed to install the application using the syntax below.
    adb install [path_to_apk]
    

    E.g.

    adb install QuickPic.apk

    word image 199

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.

word image 200

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.

  1. Install the necessary packages required to run the installation script on your system.
    sudo apt install wget curl lzip tar unzip squashfs-tools
  2. Clone the Anbox Playstore Installer script on your system using the command below.
    wget https://raw.githubusercontent.com/geeks-r-us/anbox-playstore-installer/master/install-playstore.sh
  3. Make the script executable using the chmod command.
    chmod +x install-playstore.sh
  4. Run the script with the command below.
    ./install-playstore.sh

    word image 201

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.

  1. Launch the Settings app from the Anbox window
  2. Scroll down and click on Apps -> Google Play Services.
  3. Select Permissions and enable the permissions you want
  4. Repeat this process for the Google Play application.
    word image 202

That’s it! You can now proceed to install the application from the Play store.

Wrapping Up!

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

  • Genymotion
  • Android Studio
  • Archon

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

  • Android-x86
  • BlissOS.

Have a good time running Anbox on your system, and don’t hesitate to hit the comments section if you come across any errors.

8 Shares:
Subscribe
Notify of
guest
Receive notifications when your comment receives a reply. (Optional)
Your username will link to your website. (Optional)

0 Comments
Inline Feedbacks
View all comments
You May Also Like