安卓系統源碼添加自己的可執行文件到system/bin目錄


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編譯打包進系統

  1. adb shell
  2. cd /system/bin
  3. ./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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM