How to include a binary file with Android NDK project?
I know its bad practice but whats the best way to include a binary file with Android NDK project? The file should be executable with the system command.
I don't want to copy it manually copy to the device but distribute it within my .apk.
It is enough to rename the executable to "lib_myexecutable_.so" and put it in libs/armeabi folder under your project root: this file will be extracted by the Package Manager on the device to /data/data/your.package.full.name/lib, with executable permissions.
If you use ndk-build to build myexecutable, all ./libs/$(TARGET_ARCH_ABI) directory will be refreshed.
To automate the rename operation, use the following in your Android.mk:
... # whatever you have to define the executable include $(BUILD_EXECUTABLE) # immediately after this, all: .libs/$(TARGET_ARCH_ABI)/lib_myexecutable_.so .libs/$(TARGET_ARCH_ABI)/lib_myexecutable_.so: $(LOCAL_INSTALLED) <tab>$(call host-mv, $<, $@)