I have a native binary that I want to include into Android's source code, so that when I compile it my binary will be included in /system/bin .
I've copied my binary into the folder /prebuilt/android-arm/my-binary , and I've created a new Android.mk with the following:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := my-binary
LOCAL_MODULE := my-binary
LOCAL_MODULE_CLASS := EXECUTABLES
LOCAL_MODULE_TAGS := optional
include $(BUILD_PREBUILT)
But when I run make, the only reference I get in the log is the following:
target Prebuilt: my-binary (out/target/product/generic/obj/EXECUTABLES/my-binary_intermediates/my-binary)
And the binary isn't installed into system.img at all. There's an almost identical question in Installing a prebuilt binary on Android: "not found" , but the asker already knew the basic procedure and it isn't explained at all. If I run make my-binary, I get the same line I posted.
I've also tried to run make out/target/product/generic/system.img my-binary but it doesn't work either. My binary shows up in the the out subfolder but it won't be included into system.imng
Am I missing something? Is there any way so that with just running make -j# my binary will be included in /system/bin ?
Just tested on my emulator and it's working. I used as an example gdbserver in this folder. I have a strace crosscompiled for android and use it to be embedded into the image. So, the instructions will be for this executable.
Add Android.mk file with the following content:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := strace
LOCAL_MODULE := strace
LOCAL_MODULE_CLASS := EXECUTABLES
LOCAL_MODULE_TAGS := optional
include $(BUILD_PREBUILT)
prebuilt_files :=
$(call add-prebuilt-files, EXECUTABLES, $(prebuilt_files))
Build with the instruction: mmm prebuilt snod -j4
(if you have images already built) or you, of course, can use make -j4
as well.
if your binary ends up in the out directory but not in the image, it's because you don't have a rule to include the binary in the image.
in device/<vendorname>/<devicename>/device.mk
(or in some makefile included by device.mk
) you need to have one of two entries:
PRODUCT_PACKAGES += my-binary
or:
PRODUCT_COPY_FILES += path/to/my-binary:/root/target/path/to/my-binary
... I would suggest the PRODUCT_PACKAGES
approach; PRODUCT_COPY_FILES
is better suited to scripts and configuration files.
NOTE: PRODUCT_PACKAGES
uses the module name, where PRODUCT_COPY_FILES
uses the actual name/location of the binary.
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