I have been trying to get the su binary included in the /out/.../system/xbin/su after building Android from source. I have the su binary (from Chainfire) as an executable file but I can't seem to get it included in the AOSP build.
All the examples or solutions I've came across discussed about the following in the Android_Source_Root:
- Removing the su directory from
system/extras/
and include the su-binary directory (taken from ChainsDD) in external/. - Modify the file
system/extras/su/Android.mk
with "LOCAL_MODULE_TAGS := optional" and the filebuild/target/product/core.mk
to include su in the PRODUCT_PACKAGES.
All of those have the su.c, su.h and other files in the su directory that are used to build the su package.
What I would like to know is how to include su in the AOSP build when I have the "su binary executable file" only without the need to include the su.c or any of those files? Where should I put the su directory and what is the content of the Android.mk file?
Please advice and thank you for your time.
I managed to resolve the issue that I mentioned. The following are the 2 ways I solved the issue but I faced another issue explained in the "Issue Faced" heading.
*Note: I put the su binary file in prebuilts/su
Solution 1
I modified the device.mk file in the
device/
directory. I added the following to the file.Solution 2
I modified the device.mk file in the
device/
directory. I added the following to the file.I then added and insert the following to the
Android.mk
file inprebuilts/su/su
.Issue faced
I am unable to chmod the su binary file after it has been copied to the
system/xbin
directory. I have tried a few ways as follows but yielded no result.I added the following right after the lines in Solution 1 and it keeps giving me the error of
chmod ... file cannot be found
.I added the following in Solution 2 Android.mk file before the
include $(BUILD_PREBUILT)
line but none changes the permission of the file.Could someone please advice on how to
chmod
the file? Thank you for your time.Issues Resolved
Solution 1 (for Issue 1)
Change the permission of the file first
chmod 6755 prebuilts/su/su
. Include the following in the device.mk file in thedevice/
directory.Solution 2 (for Issue 2)
Just add the following to the Android.mk file before
include $(BUILD_PREBUILT)