當前位置:首頁 » 安卓系統 » 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

熱點內容
winformftp 發布:2025-09-14 11:04:24 瀏覽:685
三星解除加密設備 發布:2025-09-14 10:41:50 瀏覽:741
android和前端 發布:2025-09-14 10:41:07 瀏覽:946
觸發腳本嗎 發布:2025-09-14 10:40:54 瀏覽:378
紅米3手機怎麼不鎖屏密碼 發布:2025-09-14 10:34:03 瀏覽:542
C語言的後門 發布:2025-09-14 10:30:59 瀏覽:278
氯代物演算法 發布:2025-09-14 10:30:04 瀏覽:711
會員登錄php 發布:2025-09-14 10:06:46 瀏覽:251
視頻圖片存儲到哪裡合適 發布:2025-09-14 09:57:36 瀏覽:384
分鏡腳本怎麼寫 發布:2025-09-14 09:52:45 瀏覽:1003