I am looking for methods to run native ARM executable on Android 4.1 (Jelly Bean). For example, compiling the classical C program
// hello.c
#include <stdio.h>
int main() {
printf("Hello world");
}
to ARMv7a executable, say hello
using the Android NDK and then run it in Android shell. I have tried method suggested on the web such as pushing the executable to /data/local
by
adb push hello /data/local
change permission to allow it to be executed by
adb shell chmod 755 /data/local/hello
and then invoke them in the shell using
adb shell /data/local/hello
The last step fails with error:
/data/local/hello: not found
but evidently the file is there. I suspect the problem is that Jelly Bean's shell does not allow one to execute alien binaries anymore. Can anyone confirm this and give me a solution?
If you want to run a native ARM binary in Android you have to compile with -static.
The libc that you use to build (if using the standard ARM toolchain and not Android NDK) is different from Android's libc (bionic) and therefore when your binary intends to link dynamically to libc on target it will not because libc doesn't exist on target.
With the -static option you link in what you need from libc at build time and don't have to worry about linking things in dynamically.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With