当前位置:首页 » 安卓系统 » helloandroid

helloandroid

发布时间: 2023-08-03 11:42:57

‘壹’ 如何在Android系统源码中添加C项目

以hello_android为例,步骤如下:

1、在external目录下创建hello_android目录,然后在hello_android目录中编写hello_android C语言实现文件hello_android.h,hello_android.c:

(注:hello_android目录可以放置在Android系统源码下的任意目录中,并非一定要在external下。)hello_android.h

#include<stdio.h>

#include<stdlib.h>void makePrintf(char *str)

{

printf("%s", str);

}hello_android.c

#include <stdio.h>

#include <stdlib.h>

#include "hello_android.h"int main(int argc, char** argv)

{

makePrintf("hello, android!\n");return 0;

}

2、编写负责编译的Android.mk文件:

LOCAL_PATH := $(call my-dir)include $(CLEAR_VARS)LOCAL_SRC_FILES := hello_android.cLOCAL_C_INCLUDES += $(LOCAL_PATH)LOCAL_MODULE := hello_androidLOCAL_MODULE_TAGS := enginclude $(BUILD_EXECUTABLE)

3、利用mm编译生成hello_android二进制可执行文件;

4、将helllo_android文件复制到/system/bin目录下执行:

#./hello_android

hello, android!

5、代码结构

$ pwd

external/hello_android

$ tree

热点内容
拉杆箱如何修改密码 发布:2025-07-16 05:07:09 浏览:462
电脑安卓软件哪个好下载 发布:2025-07-16 04:57:08 浏览:399
动态磁盘存储池 发布:2025-07-16 04:46:34 浏览:312
php多维数组数组排序 发布:2025-07-16 04:45:19 浏览:375
炼妖壶文件夹 发布:2025-07-16 04:43:11 浏览:155
phpfile乱码 发布:2025-07-16 03:57:54 浏览:93
手机存储空间扩容 发布:2025-07-16 03:52:07 浏览:861
小米4清除缓存 发布:2025-07-16 03:03:17 浏览:563
如何缓解压力英语作文 发布:2025-07-16 03:03:15 浏览:15
手机视频怎么缓存 发布:2025-07-16 02:59:05 浏览:933