现在的位置: 首页 > 综合 > 正文

android系统编写helloworld模块,编译以及adb运行

2018年03月16日 ⁄ 综合 ⁄ 共 514字 ⁄ 字号 评论关闭
cd android4.0
mkdir external/hello
cd external/hello
vi hello.c Android.mk
cd ../..

Android.mk文件:

LOCAL_PATH :=$(call my-dir)
$(info $(my-dir))
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS :=optional

LOCAL_SRC_FILES := $(call all-subdir-c-files)
#LOCAL_SRC_FILES := hello.c
LOCAL_MODULE := hello
#LOCAL_SRC_FILES := $(call all-subdir-c-fiies)
include $(BUILD_EXECUTABLE)

hello.c文件:

#include <stdio.h>
int main()
{
	printf("hello world!\n") ;
	return 0 ;
}

编译如下:

mmm ./external/hello

adb上传

adb push out/target/product/generic/system/bin/hello /data

进入adb shell

adb shell
cd data
./hello

抱歉!评论已关闭.