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

熱點內容
c是高級語言嗎 發布:2025-03-17 12:16:31 瀏覽:521
python泛型 發布:2025-03-17 12:15:01 瀏覽:480
編程貓被盜 發布:2025-03-17 12:02:18 瀏覽:130
海關鎖密碼箱如何設置新密碼 發布:2025-03-17 11:53:50 瀏覽:559
農業卡號的密碼在哪裡改 發布:2025-03-17 11:48:57 瀏覽:965
楊瀾超級訪問 發布:2025-03-17 11:47:17 瀏覽:237
資料庫無損連接 發布:2025-03-17 11:47:16 瀏覽:13
memcachephp類 發布:2025-03-17 11:40:04 瀏覽:829
哈夫曼編碼演算法實現 發布:2025-03-17 11:23:31 瀏覽:385
錄音機可以存儲信息嗎 發布:2025-03-17 11:13:32 瀏覽:174