Native linux apps on android

Can Linux apps be run in Android?

Maybe you could clarify your question? In theory you can teach an elephant to dance, but that does not mean that when you meet a wild elephant in a jungle, it will dance for you. Are you asking for the technical possibility, and you are ready to write and compile some code, root your device etc, or do you seek an out-of-the-box/install-a-single-app solution?

It might be easier to go the other way around — running Android packages in a Linux system. That might be something to look into anyway.

15 Answers 15

In general, no. Android apps generally run in a sandboxed Java-like virtual machine, so have to be written in Java or some language that compiles to virtual-machine bytecode that use the Android API.

However, the virtual machine does run on top of the underlying Linux OS, and there are ways to call native code. See https://developer.android.com/tools/sdk/ndk/index.html

So, while it is technically possible to run native Linux programs, as there is a Linux kernel running beneath everything, most users would not be able to install such applications or use them. (If you have root access or are building your own firmware, then you can do whatever you want.)

That’s a rather indirect answer. Yes, Android can run Java apps, since it’s a Linux distribution that comes with a JVM. But that JVM is obviously a native application itself, so there is at least one native Linux application that can run on Android/Linux.

Actually, Android doesn’t come with a JVM, it comes with a Dalvik VM. The Dalvik VM comes with a Java language implementation that compiles down to Dalvik bytecode, but not to JVM bytecode. I believe there’s also a tool that can convert compile JVM bytecode into dalvik bytecode. Wikipedia (as usual) has a pretty good introduction to Dalvik: en.wikipedia.org/wiki/Dalvik_virtual_machine

I don’t think it’s an «indirect answer.» I understand the question to mean «Can a typical user install native Linux applications on Android.» I think the answer to that is No, but obviously, as Android runs on top of Linux, there are native Linux programs running.

It should be noted that you can build android binaries with the NDK and use an existing terminal emulator (like connectbot) to avoid writing any java. Android will execute binaries targeted for bionic. some examples I built for myself: wyatt8740.no-ip.org/android.html — also, you don’t need root. Normal users can execute in /data/local/tmp .

Yes you can. I have installed a complete Debian distribution in a chroot-jail enviroment using debootstrap. (You need a rooted device) I am now running ssh, apache, mysql, php and even a samba server under android on my htc-desire with no problems. It is possible to run x applications using a remote x server via ssh. It even runs openoffice.org and firefox. You can use this: http://code.google.com/p/android-xserver/ to run X-application on localhost but my HTC-desire has a to small screen to be productive 🙂 But it might be usefull on a Eee Pad Transformer or something like that.

Читайте также:  Windows прочитать диск linux

Hey, that’s a valid answer. However, essentially Android can be augmented to run «Linux apps» and that’s what you done.

You mentioned that you installed a «complete Debian distribution» and ran apps under Android. How is that? These are different OS. So you probably ran apps under Debian?

Android does not run X Windows, nor does it have many of the standard GNU libraries. So, since most native linux applications require one or both of these, most will not run.

In addition, even Java programs can be limited, because the version of Java that Android applications are written in is a subset of the standard Java library.

Not directly, no. Android’s C runtime library, bionic, is not binary compatible with the GNU libc, which most Linux distributions use.

You can always try to recompile your binaries for Android and pray.

Nothing prevents you from adapting your code. Bionic has most of what glibc does, and what doesn’t exist can be implemented. I’ve compiled even things like imagemagick, GnuTLS, and ncurses for android.

The old link is dead it was for a Debian install script There is an app for that in the android market but you will need root

That link is dead. It’s helpful to give the gist of the solution in the answer, so it’s useful long after the links have died.

android only use linux kernel, that means the GNU tool chain like gcc as are not implemented in android, so if you want run a linux app in android, you need recompile it with google’s tool chain( NDK ).

You can get an ARM cross compiler that runs on Linux here. You can also download the Android NDK and compile some command line apps. I do not have any personal experience with using C++ with either solution, but I have compiled a few simple things with both. It is my understanding that the NDK is not a full C++ compiler as there have been complaints that it will not compile some common C++ code.

Note that since I am a new user, I cannot post the NDK link. :/

yes i have done that on several rooted machines i set a debian linux on a sdcard by dd. i copy this script http://jeanmichel.gens.free.fr/etc/install on /system/bin

i have not yet succeed to run a Xserver but i can use xwindows binaries through the android Xserver application

i can run update my debian with apt-get upgrade , run an apache server with PHP , run a ssh server and all binaries on a terminal including user management i have also a problem with semaphores handling please contact me if you have any trouble

Yes they can if they’re compiled under an arm linux first or using a cross compiler. Debian arm versatile works, there’s also arm-eabi for compiling under x86 linux to arm linux.

Читайте также:  Linux свойства сетевого адаптера

Yes, they can. If you do not have a rooted phone/tablet, then you could download c4droid here to compile your apps. Then, you could download Kevin Boone’s KBOX here to run the program.

Hell, of course yes, with several limitations.

Android is a kinda special Linux distribution, with no usual suff like X11, and you can’t install Apache2 with apt-get. But if you have ARM cross-compiler, you can copy your ELF files to the device, and run it from a terminal app or if you have installed some SSHD app, you can even use SSH from your desktop/notebook to access the Android device.

To copy and launch a native Linux executable, you have not root your device. That’s the point, where I am, I’ve compiled my own tiny webserver to Android (and also for webOS), it runs, hallelujah.

There comes the issues, which I can’t answer:

  1. My tiny webserver use only stdlib and pthreads. I have no idea how to use the (native Linux) libraries comes with Android, there are useful ones, altough, I can live without them.
  2. Now I can launch my app from a terminal app by hand. But I don’t know, what’s the best way of deploying such native apps to Android. I think I should be write a small Android app, which launches the server and not letting automatically stopped by the system (say, as like music players never killed). Also, if its a service, it should somehow started on boot. I’m not familiar with Android.

I think the best deployment method would be a modified version of connectbot or another FOSS terminal emulator with your binaries packaged with it.

Short answer, no. Long answer, you can run Linux application if you install some software.

To avoid rooting your device, you can try the GnuRoot and XSDL combo to get a minimal chrooted environment, (Actually, it use proot to enable a rootless chrooted jail), or get the Debian Noroot application, which combine the former two application in a single virtual machine environment. Both can be fetch from Google Play.

However, there is a few drawbacks: first, the X11 Server bundled by XSDL and DNR is a compatibility layer wrapped around a Android port of SDL library and SurfaceFlinger. This means, hardware accelerated OpenGL graphics are not avaliable, and even the sound support requires some hacks. So, the author choose a simple Desktop Environment: XFCE4 suitable to low memmory and no 3D support. The second problem is the incompatibility from the DNR Virtual Machine of direct hardware acess, since it requires real root privileges. So you can’t burn DVD, print using USB cables. even the author’s projects may promise a workaround in a future. Finally, this solution enables to install user-space programs like LibreOffice, Gimp, Samba. not kernel-space modules.

Читайте также:  Linux list listen port

Even with this limitations, the DNR is a very powerfull program.

You can install chrooted linux distribution alongside android bacause android is based on linux kernel. If your phone is not rooted, you may use fakeroot (easiest way is to use Debinan nonroot app) even with GUI (with android X-server app or via VNC). If you have a rooted phone, you can install almost fully functional distribution.

I think the best performance and the least limitations you can achieve with Gentoo because all software compiles to your native arm architecture and it is the most flexible, but not the easiest. You may be interested in this post about installing Gentoo on android.

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.

Источник

Оцените статью
Adblock
detector