You need to deploy the binary to the file system, to a location which is not marked as non-executable (that's why /sdcard/
and other common places don't help). You need to choose the version of your executable that matches the platform (armeabi, or x86, or mips). You should make sure that the file you deployed has the eXecutable permission.
The easiest way to ensure all this is to copy the arm build of your binary to ${project_root}/libs/armeabi/lib_myProgram_.so
, and same for other relevant ABIs. Now the APK builder will pack the binary(s), and the installer will unpack them (with eXecutable permissions) to /data/data/
your.package.name.with.dots/lib/lib_myProgram_.so
.
All this done, you simply call from Java (the following line can be called from Activity or Service, which have access to context):
Runtime.getRuntime().exec(getContext().getApplicationInfo().nativeLibraryDir + "lib_myProgram_.so");