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

熱點內容
android底部導航欄滑動 發布:2025-10-16 15:14:13 瀏覽:930
為什麼塞班系統不能像安卓一樣 發布:2025-10-16 15:13:14 瀏覽:701
編程能編寫 發布:2025-10-16 15:08:02 瀏覽:874
編譯器為什麼建議安裝在c盤 發布:2025-10-16 15:07:48 瀏覽:288
c程序設計語言目錄 發布:2025-10-16 14:44:22 瀏覽:413
linux如何改伺服器名字 發布:2025-10-16 14:30:51 瀏覽:479
apacheforlinux安裝配置 發布:2025-10-16 14:14:59 瀏覽:764
手機存儲卡插在哪 發布:2025-10-16 13:55:57 瀏覽:745
mysql建資料庫編碼 發布:2025-10-16 13:43:08 瀏覽:341
php冒泡排序 發布:2025-10-16 13:43:07 瀏覽:92