5

I am trying to port Android apps to Linux (don't laugh :) and I have come across a problem. When trying to execute an Android executable (app_process) after adding the executable permission with ./app_process it says it doesn't exist although cat ./app_process works.

Also in my file manager (Pantheon Files) the executable shows the shared library icon.

Is there any way to get these execute on Linux.

  • what does file app_process return? – Centimane May 20 '16 at 14:31
  • It says ./app_process: symbolic link to 'app_process32' – Suici Doga May 20 '16 at 14:33
  • Also file ./app_process32 says ./app_process32: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), stripped – Suici Doga May 20 '16 at 14:34
  • If it's a shared object it should be possible to execute it. Try strace -f -e trace=open,read,stat ./app_process32 and post the output (it might be long) – Centimane May 20 '16 at 14:45
  • @Dave It says strace: exec: No such file or directory +++ exited with 1 +++ . The file does exist and cat works – Suici Doga May 21 '16 at 1:26
10

Android and Linux are two different operating systems. You can't just take an executable from one and run it on the other.

The first hurdle is the kernel. Android and Linux are based on the same kernel, but they have a few different features. In particular, Android provides binders, which only exist in the mainstream kernel (the one found in Linux distributions) since version 3.19. A pure native-code application might not use binders but most Java apps do.

The second hurdle is the dynamic libraries. If you have a dynamically-linked executable, it invokes the dynamic linker. Android and Linux have different dynamic linkers, and if the dynamic linker is not present, you get the same error as if the executable itself was not present.

If you copy the dynamic linker, and the configuration files that it needs, and the native libraries, then you should be able to run most native programs. You'll need to copy most of /system, and the copy needs to be located at /system.

If you want to run Java apps, it's more complicated. You need the Java runtime environment (Dalvik/ART), and most apps require some Android daemons as well (some native-code apps also require those demons).

The upshot is that while the two systems can cohabit on one kernel, this needs to be a recent enough kernel, or an Android kernel (an Android kernel can run most Linux applications), and both operating systems need be installed — you can't just run an application from one on the other.

I'm not aware of any ready-made installer for Android on top of Linux. There are installers for the other way round, however, in particular LinuxonAndroid.

If the objective is to run an Android app on a Linux system, then the easiest way by far is to run it inside the emulator which is part of the Android development tools.

  • I copied everything in /system from a Android x86 ISO – Suici Doga May 21 '16 at 1:01
  • I have kernel 3.19.0-59-generic – Suici Doga May 21 '16 at 1:34
  • Running /lib/ld-linux.so.2 ./app_process32 gives me a segmentation fault – Suici Doga May 21 '16 at 1:35
  • @SuiciDoga /lib/ld-linux.so/2 is the Linux dynamic linker. You need to use the Android dynamic linker. On ARM that's /system/bin/linker, I don't know if x86 uses the same name. – Gilles May 21 '16 at 13:45
  • How do I execute an executable with Android's linker. Android x86 has this file but it has the same library icon – Suici Doga May 24 '16 at 12:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.