当前位置:首页 » 安卓系统 » 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-09-14 10:41:50 浏览:740
android和前端 发布:2025-09-14 10:41:07 浏览:944
触发脚本吗 发布:2025-09-14 10:40:54 浏览:377
红米3手机怎么不锁屏密码 发布:2025-09-14 10:34:03 浏览:541
C语言的后门 发布:2025-09-14 10:30:59 浏览:277
氯代物算法 发布:2025-09-14 10:30:04 浏览:710
会员登录php 发布:2025-09-14 10:06:46 浏览:250
视频图片存储到哪里合适 发布:2025-09-14 09:57:36 浏览:383
分镜脚本怎么写 发布:2025-09-14 09:52:45 浏览:1002
sql10 发布:2025-09-14 09:51:05 浏览:696