1、找到路徑源碼路徑 external 下面添加一個hello文件夾
2、添加 Android.mk文件,寫入代碼
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_CFLAGS += -Wno-unused-const-variable -Wno-unused-variable -Wno-unused-parameter
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := hello
LOCAL_SRC_FILES := $(call all-subdir-c-files)
include $(BUILD_EXECUTABLE)
3、添加 hello.c文件
寫入代碼
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
printf("hello word \n");
return 0;
}
4、打開終端,cd 安卓系統源碼路徑,
然后. build/envsetup.sh
lunch
選擇序號
然后 mmm ./external/hello 編譯。
make編譯打包進系統
- adb shell
- cd /system/bin
- ./hello
或者
mmm ./external/hello
adb root
cd /home/ub/bin/ad10/out/target/product/generic_x86_64/system/bin/
adb push ./hello /system/bin
直接把可執行文件push到安卓系統目錄
完成。。。
參考
https://blog.csdn.net/xipiaoyouzi/article/details/40144233