Can Linux apps be run in Android?

Viewed 113279

Android is based on Linux; can native Linux applications be run on Android?

16 Answers

It depends on what you mean by "Linux applications", and what you hope to achieve.

First, if you mean, can you copy an x86-64 Linux binary executable to an Android device running on an ARMv7 processor, and run it... well no, that won't work at all, for several reasons.

If you mean, can you run Linux programs within a Linux emulator running within Android, sure... with limitations. Have a look at "Termux". With that, you can run many command-line applications. With a VNC server running in Termux, you can run some Linux X GUI applications, and use them in a VNC client (See the Termux Wiki). There is also "Termux:GUI" --- I've never tried it.

If you mean, is it possible to compile applications meant to run under Linux, so that they can run as native Android apps, well, that depends.

Up to Android 4, you could cross-compile a C "Hello World" for ARMv7 under Linux, adb push it over to an Android phone, and run it in an Android terminal emulator. I have done it. But the security model of more recent Android systems makes that much trickier: there is no way to give such a file Linux executable permissions. (chmod 777 does not function.) On a rooted device, such things are still possible.

I suspect that it is possible to install native ARMv7 binaries (even without the NDK --- say, just a "Hello World", which doesn't require all that), along with an Android app installation, so that it is executed from the app. It's only a matter of permissions. I haven't yet figured out how.

But a "Hello World" isn't really a Linux application. A Linux application would make use of the Linux system and libraries. And even on a rooted device, what remains of Linux in Android is terribly limited and altered. You would have to build up the necessary software infrastructure to run a more elaborate application. And that might be an impractical task.

But if you're going to do that... wouldn't it be better to just root the device, and install Linux on it? That can be done, too. Sometimes.

these are all total lies above

  1. Android x86 pie uses linux kernel 4.19 with most PC kernel modules DISABLED (you have to rebuild the kernel yourself for PC hardware - for VM maybe not)

  2. Android installs unix (GNU+freebsd+ubuntu parts google threw together) in, was it, /system/bins

there seems to be some heavy lying going on by ubuntu, rh even android about whether Android has a linux OS

it most certainly does: and, the Java is Sun/Oracle java, and it is intalled as a linux version, and requires a linux OS to load it

  1. You cannot build an app for phones, say it is "for Android" that doesn't sandbox and breaks Android: it's against policy and they will come after you and remove your app off the store for good reasons. HOWEVER: you can do it at home on your personal android if you can afford to be an unpaid developer :)
Related