Ultimate Guide to install Anbox in any Arch-based distro(especially Garuda)

  1. Choose a kernel from here: List of Arch Linux Kernels patched for Anbox.

    [ Anbox works with following kernels :-

  • linux-zen (it is in the Arch Official Repositories),

  • linux-tkg-bmq (it is in the chaotic-aur for Garuda users),

  • linux-cacule (it is in the chaotic-aur for Garuda users,
    for more details refer:https://forum.garudalinux.org/t/linux-cacule-feedback-testing)

  • linux-xanmod-anbox (it is in the chaotic-aur for Garuda users),

    *(Anbox doesn't work with linux-lts) ]

    However, you could use any of the kernels from the above link and follow similar steps to install the kernel and the corresponding kernel header.

  1. To install the Xanmod kernel:
    sudo pacman -S linux-xanmod-anbox linux-xanmod-anbox-headers
    or
    To install the Zen Kernel:
    sudo pacman -S linux-zen linux-zen-headers
    or
    To install Linux-tkg-bmq:
    sudo pacman -S linux-tkg-bmq linux-tkg-bmq-headers
    or
    To install Linux-cacule:
    sudo pacman -S linux-cacule linux-cacule-headers
  1. Reboot and choose the patched kernel that you just installed

  2. Setting up Kernel Modules:

i) To enable module loading at boot, create a file inside /etc/modules-load.d/, which contains the lines:
(sudo nano /etc/modules-load.d/anbox.conf)

/etc/modules-load.d/anbox.conf

ashmem_linux
binder_linux

(Save and exit)

ii) Load Modules: sudo modprobe -a binder-linux ashmem-linux
(You can skip this step for linux-tkg-bmq)

iii) To enable creating mount point of binderfs at boot, create a file in /etc/tmpfiles.d/ with the content:
(sudo nano /etc/tmpfiles.d/anbox.conf)

/etc/tmpfiles.d/anbox.conf

d! /dev/binderfs 0755 root root

(Save and exit)

iv) Mount binderfs:

  • sudo mkdir -p /dev/binderfs
  • sudo mount -t binder none /dev/binderfs

v) To enable mounting binderfs at boot, add a line in the fstab. Using the option nofail here will not greet you with a recovery shell when you are booting a kernel without binderfs support (such as the standard kernel).:
(sudo nano /etc/fstab)

/etc/fstab

none                         /dev/binderfs binder   nofail  0      0

5) Setting up Anbox:

i) Install Anbox:
You can install it from Garuda Gamer -> Emulators. It will install Anbox with all necessary dependencies and even Google PlayStore

ii) Configure Networking:

sudo systemctl enable --now systemd-networkd

iii) Enable the Container Manager Service:

sudo systemctl enable --now anbox-container-manager.service

iv) Enable the Session Manager Service:

systemctl --user enable --now anbox-session-manager.service

v) If you want to use adb to debug, install android-tools:
sudo pacman -S android-tools

  1. To check modules status
  • lsmod | grep -e ashmem_linux -e binder_linux
    example output:
 binder_linux          147456  79
 ashmem_linux           16384  23
  • we can also check like this:
    cat /proc/filesystems | grep binder # output should like:nodev binder
    cat /proc/misc | grep ashmem # output should like: 56 ashmem

    or

  • sudo ls -1 /dev/{ashmem,binderfs}

[For more details refer to: https://wiki.archlinux.org/index.php/Anbox#Installation]

This post is a simplified version of this one: https://forum.garudalinux.org/t/a-little-help-with-anbox/

           There you are, enjoy Android Apps in Garuda Linux!
7 Likes

Very nice, thanks! :slight_smile:

1 Like

If I ask your advice, which kernel is better? I don't want to run both of them.

@dr460nf1r3, I have decided to use Linux-Xanmod, hope it doesn't disappear from the repositories :grinning:

For me Xanmod is better than Zen, choosing a kernel is highly dependant on the setup you run so it might not apply for you. Best is to just test :wink:

Noted, trying to keep it updated :slight_smile:

3 Likes

Thanks a lot.
You people are doing a great job with this distro. :smiley: :wink:

2 Likes

I thing tkg-bmg it works best with my mac.

1 Like

Edit - UPDATE: I still cannot enter developer options and therefore can't turn on USB debugging however I am now signed in with Google Play Services/Store and was able to get Magisk launched and updated... I thought I had configured my firewall correctly to allow anbox0 to connect but I was wrong. That was the hitch with those 2 issues. So unless anyone can think of why I might need USB debugging now that I can install apps/magisk modules, I think I can call it a day and chalk this up to (mostly) user error. Not that I really see much of a need to do this but out of curiosity, can ROMs be flashed using a flashing tool on anbox (thereby circumventing any need for USB debugging for flashing ROMs)?

I don't see anyone else mentioning any issues so I'm going to assume I'm alone here but maybe that means one of you are able to point me in the right direction or point out where I went wrong - install process went buttery smooth and Anbox launches just fine. Network connection/Anbox0 bridge is up and running, too. My issue is that I can't enable USB debugging and therefore can't install any apps AFAIK. I can open settings and tap "Build Number" 7 times to enable Developer Options, however when I click on Developer Options, anbox thinks for a moment and then settings/anbox crashes (sometimes just settings, sometimes the entire application). I wasn't surprised that I couldn't sign in with Google in order to use the Google Play Store but was left asking myself why it would be included if it wouldn't work. I thought perhaps clearing cache might help but clicking on Backup and Reset yields the same result as clicking Dev Options, i.e., crash. I was hoping that maybe USB debugging would be enabled by default once Dev Options are unmasked but no dice, ADB doesn't list it under devices.

For a little background, I've tried using both the xanmod-anbox and tkg-bmq kernels with the same result. Perhaps worth noting that I'm actually using tkg-bmq-zen2 since I'm on zen2 arch, but I can't imagine that would make any difference, or am I wrong to make this assumption? Outside of that, I didn't stray from the instructions at all. The only other thing I can think of to make note of is that I did not skip the "Load modules" step, both because I wanted to be able to run anbox using other kernels and because of the slight/zen2 difference. Again, if I was a fool to do this, please don't hesitate to tell me so.

Lastly, and this may not be relevant but I cannot launch Magisk. It just displays a black/blank screen for a few seconds before crashing.

Of course I searched the internet high and low for insight and there are mentions of others having this issue but nothing in the way of a fix, so any insight would be awesome! THANKS!

edit - in my search for a fix I came across someone pointing to $XDG_RUNTIME_DIR not being defined but as far as my limited knowledge/experience in that area would take me and from what was indicated in that thread, there was nothing wrong with how anbox was configured on my system (though I can't help but have my doubts based on the terminal output). I'm just not knowledgeable enough on the subject and haven't yet changed that fact but the instructions given here by @Austin (thank you very much for taking the time to compile this set of instructions, btw) seem to be presented as a more or less total package and they make no mention of any need to mess with $XDG_RUNTIME_DIR...

╭─sir_paul at 4x4-BOXPC in ⌁
╰─λ echo $XDG_RUNTIME_DIR
/run/user/1000
╭─sir_paul at 4x4-BOXPC in ⌁
╰─λ sudo systemctl --user enable anbox-session-manager.service
[sudo] password for sir_paul:         
Failed to connect to bus: $DBUS_SESSION_BUS_ADDRESS and $XDG_RUNTIME_DIR not defined (consider using --machine=<user>@.host --user to connect to bus of other user)
╭─sir_paul at 4x4-BOXPC in ⌁
╰─λ echo $DBUS_SESSION_BUS_ADDRESS
unix:path=/run/user/1000/bus

Yeah, it happens to me too,
but I can sign in and use the Play store, but, it doesn't make any difference cause non of the apps I installed launched.

The only other thing I can think of to make note of is that I did not skip the "Load modules" step, both because I wanted to be able to run anbox using other kernels and because of the slight/zen2 difference. Again, if I was a fool to do this, please don't hesitate to tell me so.

I don't think, it would have caused any issue, I mentioned skipping 'Load module' in tkg-bmq because
because when I tried to run the command: sudo modprobe -a binder-linux ashmem-linux, I found that there were no such modules in tkg-bmq,
but running: sudo modprobe -a binder, did work.
But then, it still worked without running the Load module command.

By the way, I am no expert in all the technicality you are talking about (I am just a newbie to Linux). I have no idea about USB debugging and all that and I am sorry to say you may not find anyone, who might be knowing all this stuff. I think nobody is that interested in Anbox in this forum.

I just wanted to try and learn about running android in Linux, cause Chrome Os is just a container like Anbox on top of I think, Gentoo. Though I can just simply multi-boot Chrome Os [Chrome OS + Windows + Linux Triple Boot Install on PC or Laptop] in my system (I have Garuda, Fedora, MX Linux & Windows, installed on my machine), having able to run android in Linux itself would be just great. I have heard that Windows is trying to integrate the Android app into it.(I rare use Windows and I am trying to use as less as possible)
Anbox seems to be promising, but its development is slow.
And I am just looking forward to running android in Linux and lean more about it.

thank you very much for taking the time to compile this set of instructions, btw)
:wink:

1 Like

Hi all,
I think I'll give this one a try in the next days.

Looks promising, since unlike Anbox (or better the relevant android-images) this one seems more up-to-date (up to Android 11).

4 Likes

If anyone succeeds in running it please make an article to run it in Garuda Forum,
I will try to do so too

linux-cacule got updated today and anbox support has been added.

Take a watch here:

https://forum.garudalinux.org/t/linux-cacule-feedback-testing/7672

Github:

4 Likes

Hello everybody.
I just wanted to leave you my feedback on some quick tests done earlier.
I initially tried ReDroid on my default (zen) kernel and it didn't work (the docker instance was not created at all, although I didn't investigate in e.g. the logs).
In fact, I had previously tried manually compiling the ashmem_linux and binder_linux modules but got errors, which all in all I expected as I had previously read something about the fact that the zen kernel does not need those modules.
Then I installed the Linux-Cacule kernel, the pre-compiled one, since I don't know how to compile it manually :blush: and at this moment I didn't have time to "study" on it a bit ...
The Linux-Cacule kernel works fine for me, I haven't noticed any performance differences, but my laptop is definitely low-end, so this is kind of expectable...
With this kernel however, I was able to load ashmem_linux and binder_linux modules.
In this way, ReDroid worked, in the sense that the instance was created and I could connect via VNC and Android started, but it was so slow and laggish that I gave up.
I read only later that it should work better with scrcpy. Maybe one day I will try it, but I was quite / too much disappointed by the performance. Maybe that's why I had always read that Anbox was a better solution than all emulators, since it is not in fact an emulator.
Of course, Anbox also worked with Linux-Cacule (I only started it and made a few easy settings changes and connected to Google Play Store).
But my problem remains, I think due to the old Android image, that Roblox (my real goal, for my kids :slight_smile:, and to get rid of windows...) doesn't start...

3 Likes
  • Install kernel modules:

sudo bash -c "curl -s https://raw.githubusercontent.com/remote-android/redroid-modules/master/deploy/build.sh"

  • start ReDroid instance and connect via VNC
    docker run -v ~/data:/data -d -p 5900:5900 -p 5555:5555 --rm --memory-swappiness=0 --privileged redroid/redroid:10.0.0-latest redroid.vncserver=1

    explains:
    -v ~/data:/data -- mount data partition
    -p 5900:5900 -- 5900 for VNC connect, you can connect via VncViewer with :5900
    -p 5555:5555 -- 5555 for adb connect, you can run adb connect localhost

    • OR start ReDroid instance and connect via scrcpy (Performance boost, recommended)
docker run -v ~/data:/data -d -p 5555:5555 --rm --memory-swappiness=0 --privileged redroid/redroid:10.0.0-latest
 adb connect <IP>:5555
 scrcpy --serial <IP>:5555

Did you work out by following these steps or was there anything else to do.

I didn't quite, understand the github page ( I am new to all these things)

By the way, scrcpy is in chaotic aur.

Would you please point out the steps you followed to start ReDroid

1 Like

I take a watch to find a kernel patch / modules for redroid.
Since I have never used anbox I’m not familiar with that. (iOS/MacOS User / don’t hate me xD)

3 Likes
❯ sudo modprobe -a binder-linux ashmem-linux
[sudo] password for austin:      
modprobe: WARNING: Module binder-linux not found in directory /lib/modules/5.12.0-6-cacule
modprobe: WARNING: Module ashmem-linux not found in directory /lib/modules/5.12.0-6-cacule
❯ sudo modprobe -a binder ashmem
modprobe: WARNING: Module binder not found in directory /lib/modules/5.12.0-6-cacule
modprobe: WARNING: Module ashmem not found in directory /lib/modules/5.12.0-6-cacule
❯ sudo modprobe -a binderfs
modprobe: WARNING: Module binderfs not found in directory /lib/modules/5.12.0-6-cacule
❯ sudo systemctl enable --now systemd-networkd
❯ systemctl --user enable --now anbox-session-manager.service
❯ sudo systemctl enable --now anbox-container-manager.service

Tried all this, but anbox not launching.

Yes, I followed that guide, but not the initial part "Install Kernel Modules".
For that part, they provide a script (build.sh) but this includes only commands for debian/ubuntu or redhat. So, I tried to do manually what is written in that script.

  • you should install git kmod make and your linux-headers, but I just checked the availability of kmod (so did not install it) and did not install also the rest, git because I had already used it, so I knew I had it, as well as the linux-headers.
  • sudo su
  • cd /root
  • git clone https://github.com/remote-android/redroid-modules.git
  • cd redroid-modules && make install
    That gave me errors (I kept notes, but in this moment I'm not on that laptop).

Second try:
I installed the Linux-Cacule kernel, I tried again as above to "Install Kernel Module" but with no luck.
Then I tried simply to follow the Anbox procedure (Anbox - ArchWiki):
sudo modprobe -a binder-linux ashmem-linux
which is equivalent to the steps in your guide (which are the "persistent" solution):

/etc/modules-load.d/anbox.conf
ashmem_linux
binder_linux

Then:
sudo docker run -v ~/data:/data -d -p 5900:5900 -p 5555:5555 --rm --memory-swappiness=0 --privileged redroid/ redroid/redroid:11.0.0-amd64 redroid.vncserver=1
(sudo with docker can be avoided creating a "docker" group and adding your user to it)
Finally I connected via TigerVNC using MyIP:5900

I think Redroid works ootb with the Linux-Cacule kernel (see my other post, "Second try").
It is terribly slow, but I'm sure this has nothing to deal with the kernel...

You mean to say all these steps didn't work for you, in that case, same with me, they didn't work.

You just loaded the anbox modules(as in my guide), and ran this command:
sudo docker run -v ~/data:/data -d -p 5900:5900 -p 5555:5555 --rm --memory-swappiness=0 --privileged redroid/ redroid/redroid:11.0.0-amd64 redroid.vncserver=1
??

when I run the same command:
sudo docker run -v ~/data:/data -d -p 5900:5900 -p 5555:5555 --rm --memory-swappiness=0 --privileged redroid/redroid:10.0.0-latest redroid.vncserver=1

the system logouts and nothing shows up.
By the way how does the redroid look?
(I am first time using docker)

Now the modules have are there after an update
Thanks