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到安卓系统目录

完成。。。