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.
- 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
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.
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 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.
- 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
anbox.appmgr
- When done, proceed to install the application using the syntax below.
adb install [path_to_apk]
E.g.
adb install QuickPic.apk
[powerkit_alert type=”info” dismissible=”false” multiline=”false”]
Tip: If you encounter the error 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.
[/powerkit_alert]
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.
wget https://raw.githubusercontent.com/geeks-r-us/anbox-playstore-installer/master/install-playstore.sh
- Make the script executable using the
chmod
command.chmod +x install-playstore.sh
- Run the script with the command below.
./install-playstore.sh
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.
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.
I have tried to follow several other tutorials to do what you have explained here. Yours worked!
My problem now is, I think, Anbox detecting an internet connection.
When open the Google Play Store app, it wants me to sign in. When I click to do so, it says “Checking Info” with a spinning loading icon for several seconds, and then says “Couldn’t sign in. There was a problem communicating with Google servers.”
I’m not sure if I have to do something unusual to enable internet connectivity for Anbox.
When I go to Settings, under Network, there’s only Wi-Fi and Bluetooth to choose from. When I enable Wi-Fi (the only option in the window), it turns off after a few seconds.
I am installing this on my desktop computer, which has a wired connection to my router. Wi-Fi does not appear to be an option.
Any hope of an addendum to this article for showing how to make Anbox connect to the internet? This was very thorough and helpful; I just need help here at the home stretch. 🙂
I do have the same problem. Did you found a solution for this problem?
Hello,
I could succesfully install anbox however I couldn’t install google-playstore. ~$ wget https://raw.githubusercontent.com/geeks-r-us/anbox-playstore-installer/master/install-playstore.sh
–2023-02-19 14:24:56– https://raw.githubusercontent.com/geeks-r-us/anbox-playstore-installer/master/install-playstore.sh
Herleiden van raw.githubusercontent.com (raw.githubusercontent.com)… 2606:50c0:8000::154, 2606:50c0:8001::154, 2606:50c0:8002::154, …
Verbinding maken met raw.githubusercontent.com (raw.githubusercontent.com)|2606:50c0:8000::154|:443… verbonden.
HTTP-verzoek is verzonden; wachten op antwoord… 200 OK
Lengte: 11661 (11K) [text/plain]
Wordt opgeslagen als: ‘install-playstore.sh.2’
install-playstore.s 100%[===================>] 11,39K –.-KB/s in 0,001s
2023-02-19 14:24:56 (7,91 MB/s) – ‘‘install-playstore.sh.2’’ opgeslagen [11661/11661]
It was stored as install-playstore.sh.2
After
chmod +x install-playstore.sh.2
and
./install-playstore.sh.2
I got the comment that it could not execute line 164
./install-playstore.sh.2: regel 164: /etc/systemd/system/anbox-container-manager.service.d/override.conf: Toegang geweigerd
Does anybody knows what goes wrong
Thanks
I got this Error when loading ashmem_linux kernel module
modprobe: FATAL: Module ashmem_linux not found in directory /lib/modules/5.19.0-43-generic
Where to install it ?