当前位置:首页 » 安卓系统 » 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

热点内容
h5加密 发布:2025-09-19 12:13:11 浏览:781
网贷系统源码下载 发布:2025-09-19 10:56:45 浏览:114
脚本被黑 发布:2025-09-19 10:51:27 浏览:506
android自定义命名空间 发布:2025-09-19 10:31:34 浏览:461
凯立德导航文件夹名称 发布:2025-09-19 10:31:27 浏览:34
狮山编程 发布:2025-09-19 10:14:45 浏览:785
androidshape画圆 发布:2025-09-19 10:13:21 浏览:837
c语言if复合语句 发布:2025-09-19 10:12:30 浏览:718
C语言有什么特点 发布:2025-09-19 09:54:54 浏览:824
c语言strupr 发布:2025-09-19 09:47:52 浏览:687