Forum How do I...?

Does Prince work on Android?

yyang
Hi, I can't find recent discussions about this, but does Prince work on Android? Especially inside Termux. Thanks!
mikeday
I'm guessing not, but we have never tried running Prince on Android! I assume it would require root permissions to install a native binary, and we would need to compile a build for the correct architecture, so I'm not sure how practical it would be.
yyang
Thanks for your answer! As far as I know, Termux primarily targets non-root users. I guess the better part of its users, myself included, don't run it on a rooted device. The official repo provides over 3000 packages, e.g. clang, texlive and pandoc. It'll be wonderful if Prince can also work close at hand.

In fact, Termux doesn't touch standard Linux directories like `/bin`, `/etc`, etc. Instead, it relies on 2 directories managed by itself: `/data/data/com.termux/files/usr` (the `$PREFIX`) for program files like `/` on Linux, and `/data/data/com.termux/files/home` (the `$HOME`) for user data like `/home/$USER` on Linux. A package may need some compatibility patches to work inside Termux, mostly to deal with non-standard paths and Android-specific libraries. Please see the Getting started page, the Differences from Linux page, and the Developer's Wiki for more info.

If you use an Android device, I highly recommend giving it a try. It's so flexible and powerful enough, like WSL1 for Android. You can SSH into it and do all sorts of things (allowed by non-rooted Android). Or even install real Linux distros into it like Ubuntu, Fedora, and Arch and play with them (patiently).

Edited by yyang

nora
Yes, Prince doesn't have native android support but you can use it within termux by installing the Linux version.
mikeday
The ARM build of Prince? I would have expected difficulties due to Android using a different libc.
yyang
@nora Are you sure? I only tried the latest Linux ARM64 musl libc version by manual extraction, and `./prince --version` reported the error "cannot execute: required file not found".
nora
sorry yyang but it should work smoothly.
yyang
@nora Thanks for the reply! Are you using the Linux ARM64 generic version, the Linux ARM64 (musl libc) generic version, or another? I tried again with the musl generic version on my phone but was rejected by the same error.
nora
I'm sorry yyang, I'm not using Linux ARM64 generic version, I think you should check https://developer.android.com/topic/generic-system-image it once.

Edited by nora

yyang
Thank you again, but I'm not sure why the Generic System Images are relevant here. As answered by @mikeday, the current packages of Prince are not specially prepared for Android/Termux. Do you have evidence that any version does run nicely?
mikeday
I suspect nora is a bot or at least not being helpful, sorry!
nora
sorry mikeday, not being helpful it means I'm a bot.
wangp
I can confirm that the Prince linux-generic aarch64 packages do work in Termux in a PRoot environment, e.g. Alpine Linux for linux-generic-aarch64-musl, or Debian for linux-generic-aarch64.

I followed the instructions here:
https://wiki.termux.com/wiki/PRoot#Installing_Linux_distributions

pkg install proot-distro
proot-distro install alpine
proot-distro login alpine
# install fonts
apk update && apk add ttf-liberation

Then unpack and run the appropriate Prince package as per normal.
yyang
Thanks a lot for your great help! PRoot does allow Prince to work perfectly in Termux, and I'm quite happy this level of indirection exists. But as lightweight as Alpine Linux is, it often feels overkill for running a CLI program, doesn't it? I still hope there could be a package of Prince that directly runs in Termux...