Running android apps on puppy natively

Moderator: Forum moderators

Post Reply
bigpuppyfan
Posts: 72
Joined: Fri Feb 12, 2021 1:20 pm
Has thanked: 11 times
Been thanked: 15 times

Running android apps on puppy natively

Post by bigpuppyfan »

I have been able to run android apps on fossapup64, using anbox (natively, ie, not using an ARM emulator) - which runs android in a container

It was quite challenging, but it's working. I will outline my summarized steps and make a guide, if someone else is interested in running this too: [btw, personally I always run puppy in PUPMODE 5, so I'm not worried of any changes this may do to the OS, but not sure how permanent/significant changes could happen in other more persistent pupmodes with save files)

1-A couple of kernel modules are necessary, one for anonymous shared memory (ashmem) and another for the FUSE filesystem (bindfs), both of which are part of the android kernel and actually included in the recent ubuntu kernels, but not in the puppy kernel. So, in terminal:

Code: Select all

pkg add-repo ppa:morphis/anbox-support ubuntu bionic
pkg repo bionic-morphis
pkg get anbox-modules-dkms

It's ubuntu bionic because the repo does not have one for focal [since the focal kernel already has these module built-in], but it makes no difference

Or, even easier than the above, just download and install:
http://ppa.launchpad.net/morphis/anbox- ... 13_all.deb
http://archive.ubuntu.com/ubuntu/pool/m ... u1_all.deb

2-The kernel sources and the devx should be installed now

3-I have found that building the bindfs module won't work and give an error - this will happen on kernels above 5.1. The solution is to replace the code of /usr/src/anbox-1/binder/binder.c with the code in https://github.com/anbox/anbox-modules/ ... r/binder.c (the repo includes an outdated version which was never updated for some reason)

4-To build and load the modules (with dkms, errors when using make):

Code: Select all

dkms add -m anbox -v 1
dkms build -m anbox -v 1
dkms install -m anbox -v 1
modprobe ashmem-linux
modprobe binder-linux

(I chose at this point to uninstall the kernel sources and devx, to free up RAM)

5-Now we should download anbox. It's a snap package. Snap packages are just like the standard sfs files Puppy uses for years, which shows how it has been way ahead - it has only recently being adopted in Ubuntu. I have found that the way to download snap packages is:

Code: Select all

curl -H 'Snap-Device-Series: 16' http://api.snapcraft.io/v2/snaps/info/anbox

[you could replace "anbox" with any another snap package btw]
The 1st link is what interests - the most stable 64 bit package

6-Once it's downloaded, just rename the file to .sfs and install it. That simple

7-Unfortunately anbox will not load, and in puppy we have to (attempt to) launch it in a different way. First, when and if anbox loads, it will probably need network access. This will bridge the current network connection to the container:

Code: Select all

sh /bin/anbox-bridge.sh start

8-We have to manually launch the manager for the container:

Code: Select all

anbox container-manager     --daemon     --android-image=/android.img     --data-path=/anbox-data

9-Anbox uses a container called lxc. Out of the snap package, it will not run because it assumes systemd, which is not used in puppy (running lxc-checkconfig will show that the Cgroup v1 systemd controller and Cgroup v1 freezer controllers are missing)

To go around this, install cgroupfs-mount (you can find it using the puppy package manager, for instance). Then run the file /usr/bin/cgroupfs-mount

And also, create this directory

Code: Select all

mkdir -p /var/snap/anbox/common/lxc

Otherwise it would not launch the container or even mention why not :roll:

10-In another terminal window:

Code: Select all

export $(dbus-launch)
anbox launch --package=org.anbox.appmgr --component=org.anbox.appmgr.AppViewActivity

Anbox will launch. Now, to obtain an internet connection, we need to:

11-Download android-tools-adb from the PPM

12-In a new terminal window:

Code: Select all

root# adb shell
x86_64:/ $ su
x86_64:/ # ip rule add pref 32766 table main
x86_64:/ # ip route add default dev eth0 via 192.168.250.1

At the moment, step 12 as to be repeated every time anbox is started.
And we now have a working android environment within puppy, able to run some android apps (not very stable yet, but that's probably anbox itself, still beta). Just needs x86 apk application packages installed as needed through the adb

Last edited by bigpuppyfan on Mon Feb 07, 2022 3:28 am, edited 3 times in total.
User avatar
wiak
Posts: 3627
Joined: Tue Dec 03, 2019 6:10 am
Location: Packing - big job
Has thanked: 56 times
Been thanked: 994 times
Contact:

Re: Running android apps on puppy natively

Post by wiak »

Looks like many issues trying to do this in Puppy. As you say it would probably be easier (maybe even easy) to do this in FossaDog. Thanks for the excellent info on Anbox though; I will try it on WDL_Arch64 sometime since that also uses systemd and full Arch package management capability and can use sfs files as part of its layers (or simply via installed snap).

https://www.tinylinux.info/
DOWNLOAD wd_multi for hundreds of 'distros' at your fingertips: viewtopic.php?p=99154#p99154
Αξίζει να μεταφραστεί;

bigpuppyfan
Posts: 72
Joined: Fri Feb 12, 2021 1:20 pm
Has thanked: 11 times
Been thanked: 15 times

Re: Running android apps on puppy natively

Post by bigpuppyfan »

I think I'm onto the cause for this not to be working in Puppy, seems to be a kernel issue after all, reported at https://github.com/anbox/anbox-modules/pull/9

Though apparently fixed https://github.com/anbox/anbox/issues/885 , I have exactly the same errors, so the interaction of ashmem with the puppy kernel is probably the problem? I have no idea on how to overcome this. In Ubuntu Focal this issue does not occur as the module is already built in the kernel. Perhaps I'll try doing the above using an old kernel and bionicpup64.

The good news is that doing the steps outlined in my previous post work in terms of loading and starting the android image...it just happens to crash when the image runs, but that is a different issue now

bigpuppyfan
Posts: 72
Joined: Fri Feb 12, 2021 1:20 pm
Has thanked: 11 times
Been thanked: 15 times

Re: Running android apps on puppy natively

Post by bigpuppyfan »

I had left this on standby - just came back to it and had a fresh look, with a few things I learned in the meantime.

The reason why this was not working was actually because I was confusing bindfs with binderfs :oops:

Anbox needs binderfs...the issue is that the puppy kernel does not support it (puppy doesn't need it). Though the module is loaded (a manual mount will be necessary):

root# mkdir /dev/binderfs
root# mount -t binder binder /dev/binderfs
mount-FULL: /dev/binderfs: unknown filesystem type 'binder'.

When looking into the logs, this seems to be why the android image was failing to load.
For it to work, the working kernel must be compiled to support ashmem, binder and android. While they are included in versions >= 5.0, they need to be manually selected when compiling.

I have no experience in compiling one unfortunately. Might have to try my luck in the kernel section of the forum if I'm not successful and ask if someone would be so kind to add these in a next release.

xx_T3n0ch_X
Posts: 36
Joined: Thu Jul 22, 2021 1:31 am
Has thanked: 3 times
Been thanked: 10 times

Re: Running android apps on puppy natively

Post by xx_T3n0ch_X »

@bigpuppyfan ,

I've managed to load anbox using FossaPup 64 9.5, however there is no internet. I just followed your instructions but I have not idea of what is going on :roll: . I have even managed to install android APKS.

anbox home screen
anbox home screen
home.jpg (16.35 KiB) Viewed 3244 times
anbox wikipedia
anbox wikipedia
wikipedia.jpg (10.06 KiB) Viewed 3244 times

here is route during an adb shell session:

Code: Select all

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.250.0   *               255.255.255.0   U     0      0        0 eth0

here is ifconfig in adb shell session:

Code: Select all

eth0      Link encap:Ethernet  HWaddr 1e:fb:1a:10:6e:2a
          inet addr:192.168.250.2  Bcast:192.168.250.255  Mask:255.255.255.0 
          inet6 addr: fe80::1cfb:1aff:fe10:6e2a/64 Scope: Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:57 errors:0 dropped:0 overruns:0 frame:0 
          TX packets:13 errors:0 dropped:0 overruns:0 carrier:0 
          collisions:0 txqueuelen:1000 
          RX bytes:13106 TX bytes:1006 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0 
          inet6 addr: ::1/128 Scope: Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:4 errors:0 dropped:0 overruns:0 frame:0 
          TX packets:4 errors:0 dropped:0 overruns:0 carrier:0 
          collisions:0 txqueuelen:1000 
          RX bytes:248 TX bytes:248 

My active internet interface in puppy linux when anbox is running changes from wlan0 to veth_someletters.

Thanks for your efforts, and for posting them.

bigpuppyfan
Posts: 72
Joined: Fri Feb 12, 2021 1:20 pm
Has thanked: 11 times
Been thanked: 15 times

Re: Running android apps on puppy natively

Post by bigpuppyfan »

That's amazing! I've been learning more about kernels in my spare time, and was going to finally try to compile one soon to support the missing features, but glad it's already working :thumbup: Which kernel did you use?

In regards to the internet, had hoped step 7 would have been sufficient, but I guess not. Perhaps this could help?

Code: Select all

sh /bin/anbox-bridge.sh restart

Otherwise, on adb, does the following sort it out?

Code: Select all

adb shell
su
ip route add default dev wlan0 via 192.168.250.1
ip rule add pref 32766 table main
ip rule add pref 32767 table local

(if not, try the above with eth0 instead of wlan0)

xx_T3n0ch_X
Posts: 36
Joined: Thu Jul 22, 2021 1:31 am
Has thanked: 3 times
Been thanked: 10 times

Re: Running android apps on puppy natively

Post by xx_T3n0ch_X »

bigpuppyfan wrote: Sat Feb 05, 2022 10:02 pm

That's amazing! I've been learning more about kernels in my spare time, and was going to finally try to compile one soon to support the missing features, but glad it's already working :thumbup: Which kernel did you use?

In regards to the internet, had hoped step 7 would have been sufficient, but I guess not. Perhaps this could help?

Code: Select all

sh /bin/anbox-bridge.sh restart

Otherwise, on adb, does the following sort it out?

Code: Select all

adb shell
su
ip route add default dev wlan0 via 192.168.250.1
ip rule add pref 32766 table main
ip rule add pref 32767 table local

(if not, try the above with eth0 instead of wlan0)

@bigpuppyfan
The suggestions above did not make any difference, as for the kernel:

Code: Select all

uname -a
Linux puppypc66 5.4.53 #1 SMP PREEMPT Sun Jul 26 12:11:02 BST 2020 x86_64 x86_64 x86_64 GNU/Linux
bigpuppyfan
Posts: 72
Joined: Fri Feb 12, 2021 1:20 pm
Has thanked: 11 times
Been thanked: 15 times

Re: Running android apps on puppy natively

Post by bigpuppyfan »

@xx_T3n0ch_X
Sorry, one more similar attempt, can you try the above, but with 192.168.250.2 instead of 192.168.250.1? The default bridge address as per the documentation is the latter, but perhaps it has defaulted to the former for some reason.

as for the kernel:

uname -a
Linux puppypc66 5.4.53 #1 SMP PREEMPT Sun Jul 26 12:11:02 BST 2020 x86_64 x86_64 x86_64 GNU/Linux

Interesting and helpful to know. It seemed to me that the original fossapup kernel had been compiled without ashmem, binder and android support. I personally have not been able to run anbox, at least not with this kernel yet, neither with a few others posted in the kernel section. Maybe I'll have to try running anbox on a different machine, as I guess the kernel modules were sufficient after all, the issue might have just been the CPU model.

bigpuppyfan
Posts: 72
Joined: Fri Feb 12, 2021 1:20 pm
Has thanked: 11 times
Been thanked: 15 times

Re: Running android apps on puppy natively

Post by bigpuppyfan »

OK, the good thing is that I too was able to launch anbox successfully in a different machine :) Puppy can now officially run android apps too :P

It wasn't launching in my usual machine as its CPU doesn't support SSE 4.2 instructions natively, which apparently was essential, so it really wasn't a kernel issue and explains why I was getting stuck (and I kept using the same outdated snap until now, probably something was fixed in the meantime that allowed for it to work on puppy)

On the other hand, I too have the same network connection problem. Will look into and update the thread if I'm able to connect

bigpuppyfan
Posts: 72
Joined: Fri Feb 12, 2021 1:20 pm
Has thanked: 11 times
Been thanked: 15 times

Re: Running android apps on puppy natively

Post by bigpuppyfan »

I was able to get a successful connection :thumbup2:

Code: Select all

root# adb shell
x86_64:/ $ su
x86_64:/ # ip rule add pref 32766 table main
x86_64:/ # ip route add default dev eth0 via 192.168.250.1

Have updated post#1's instructions, now that anbox is finally functional

User avatar
BarryK
Posts: 2268
Joined: Tue Dec 24, 2019 1:04 pm
Has thanked: 93 times
Been thanked: 562 times

Re: Running android apps on puppy natively

Post by BarryK »

I have compiled the 5.15.74 kernel with binder_linux.ko and ashmem_linux.ko modules:

https://bkhome.org/news/202210/kernel-5 ... ivers.html

Intend to have this kernel in the next release of EasyOS, then plan to have a go at running Anbox or waydroid.

User avatar
mouldy
Posts: 425
Joined: Tue Dec 08, 2020 3:53 pm
Has thanked: 24 times
Been thanked: 102 times

Re: Running android apps on puppy natively

Post by mouldy »

I get why one would want to run android apps without leaving linux. Sort of an Android WINE. But will say if you want to try android for intel, look for PrimeOS, its basically Android 11 with nice desktop, completely independent of any linux distribution. Seems to run ok though it wont run on older computer cause of same reason OP had problems with Anbox, the processor doesnt have some necessary chip, it threw up error on my old desktop mentioning this and saying it wont boot on this computer. It booted and ran fine on my converted chromebook though I only booted it off thumbdrive and didnt install it or try any challenging apps with it. But anyway, it should let you know what native Android on intel computer can be like. Seems very well done.

Oh and I looked at the Waydroid site that BarryK mentions. They offer it for download of course and links to installing it on various linux distributions, but also offer a bootable iso of Debian 12 or Ubuntu with it already installed and functional. I havent tried it cause I am on metered internet and dont really want to use the data to download it right now. But hey if you just want to see what its like.... think its Android 10. Anyway this would be a way to try it without struggling to get it installed and working first. Sometimes better to see what something can do before struggling to get it working in the Puppy universe.

Post Reply

Return to “System”