I need to deploy a native binary executable in an Android app. My approach is mostly modeled after this SO answer. The build process differs, but I deploy the native binaries as assets, which the app copies to its internal private storage as needed.
I have taken further inspiration from Termux and am building a mini directory structure in private shared storage. The executable resides in usr/bin
. However, it also depends on a library, which lives in usr/lib
.
I use the standard Java mechanism of ProcessBuilder
to start my binary. However, I figure I somehow need to tell Android where to look for the library required by the executable.
How can I tell Android where to look for libraries? Moreover, how can I ensure that my custom path takes precedence over system-wide library paths just in case there is a system-wide library which has the same name but is incompatible?