用 android build system 编译自己的app
2010-06-12 13:43
435 查看
http://cornsea.blogspot.com/2009/03/anroid-build-system-init.html
在system文件夹下
建立一个myinit文件夹
编辑一个init.c文件
代码如下
#include <stdio.h>
#include <unistd.h>
int main(int argc, char *argv[])
{
int i = 0;
while (1)
{
printf("hello world (%d)",i++);
sleep(2);
}
return 0;
}
另外建立一个Android.mk 文件,内容如下
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES:= /
init.c
LOCAL_MODULE:= init
LOCAL_FORCE_STATIC_EXECUTABLE := true
LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
LOCAL_UNSTRIPPED_PATH := $(TARGET_ROOT_OUT_UNSTRIPPED)
LOCAL_STATIC_LIBRARIES := libcutils libc
#LOCAL_STATIC_LIBRARIES := libcutils libc libminui
libpixelflinger_static
#LOCAL_STATIC_LIBRARIES += libminzip libunz libamend libmtdutils
libmincrypt
#LOCAL_STATIC_LIBRARIES += libstdc++_static
include $(BUILD_EXECUTABLE)
在myinit文件夹下输入mm,
编译系统就会自动输出一个编译好的init程序
输出的路径也会提示出来。
-------------------------------------------------------------------------------------
Another
paper in english
The android build system is complicated. It is not easy to create a
simple build script to build single component. But it is much
easier to add a new component into the build system. Here is a
sample to build the "Hello world!" for Android, and it is dynamic
linked executable.
create a directory for the new component in
$(YOUR_ANDROID)/external folder:
$(YOUR_ANDROID)/external/hello
put the hello.c into the directory:
$(YOUR_ANDROID)/external/hello/
create Android.mk in $(YOUR_ANDROID)/external/hello/ directory,
the Android.mk likes the following:
LOCAL_PATH:=$(call my-dir)
include $(CLEAR_VARS)
LOCAL_ARM_MODE := arm
LOCAL_SRC_FILES:= /
hello.c
LOCAL_MODULE := hello
include $(BUILD_EXECUTABLE)
add the following line into
$(BUILD_SYSTEM)/main.mk,$(BUILD_SYSTEM) is in
$(YOUR_ANDROID)/build/core:
external/hello
launch the build command in $(YOUR_ANDROID): make hello
you will have the build target hello in
$(YOUR_ANDROID)/out/target/product/generic/system/bin.
You can use include $(BUILD_SHARED_LIBRARY) to create shared
library. Find more in $(YOUR_ANDROID)/build/core/config.mk.
在system文件夹下
建立一个myinit文件夹
编辑一个init.c文件
代码如下
#include <stdio.h>
#include <unistd.h>
int main(int argc, char *argv[])
{
int i = 0;
while (1)
{
printf("hello world (%d)",i++);
sleep(2);
}
return 0;
}
另外建立一个Android.mk 文件,内容如下
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES:= /
init.c
LOCAL_MODULE:= init
LOCAL_FORCE_STATIC_EXECUTABLE := true
LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
LOCAL_UNSTRIPPED_PATH := $(TARGET_ROOT_OUT_UNSTRIPPED)
LOCAL_STATIC_LIBRARIES := libcutils libc
#LOCAL_STATIC_LIBRARIES := libcutils libc libminui
libpixelflinger_static
#LOCAL_STATIC_LIBRARIES += libminzip libunz libamend libmtdutils
libmincrypt
#LOCAL_STATIC_LIBRARIES += libstdc++_static
include $(BUILD_EXECUTABLE)
在myinit文件夹下输入mm,
编译系统就会自动输出一个编译好的init程序
输出的路径也会提示出来。
-------------------------------------------------------------------------------------
Another
paper in english
Add a new
component into open source Android
The android build system is complicated. It is not easy to create asimple build script to build single component. But it is much
easier to add a new component into the build system. Here is a
sample to build the "Hello world!" for Android, and it is dynamic
linked executable.
create a directory for the new component in
$(YOUR_ANDROID)/external folder:
$(YOUR_ANDROID)/external/hello
put the hello.c into the directory:
$(YOUR_ANDROID)/external/hello/
create Android.mk in $(YOUR_ANDROID)/external/hello/ directory,
the Android.mk likes the following:
LOCAL_PATH:=$(call my-dir)
include $(CLEAR_VARS)
LOCAL_ARM_MODE := arm
LOCAL_SRC_FILES:= /
hello.c
LOCAL_MODULE := hello
include $(BUILD_EXECUTABLE)
add the following line into
$(BUILD_SYSTEM)/main.mk,$(BUILD_SYSTEM) is in
$(YOUR_ANDROID)/build/core:
external/hello
launch the build command in $(YOUR_ANDROID): make hello
you will have the build target hello in
$(YOUR_ANDROID)/out/target/product/generic/system/bin.
You can use include $(BUILD_SHARED_LIBRARY) to create shared
library. Find more in $(YOUR_ANDROID)/build/core/config.mk.
相关文章推荐
- 用android build system 编译自己的init
- Android studio编译报错:Error:Execution failed for task ':app:transformClasses_enhancedWithInstantReloadD
- (转)如何发布打包并发布自己的Android应用(APP)
- Android反编译之36kr.app
- android之APP模块编译
- 【一步一个脚印】Tomcat+MySQL为自己的APP打造服务器(3-1)Android 和 Service 的交互之GET方式
- Mac OS上反编译android app的环境搭建
- Android编译系统(三):官方文档Android Build System
- android关机程序代码以及在源码中编译自己的程序
- [转]Android学习系列(31)--App自动化之使用Ant编译项目多渠道打包
- Android开发怎么让自己的APP UI漂亮、大方(规范篇一)
- Android: Receiving Data from the Send Intent,自己app注册系统分享
- 更新自己编译android源码遇到的问题
- android 给自己的app编写 用户引导(UserGuider)
- Android笔记之:App自动化之使用Ant编译项目多渠道打包的使用详解
- 这是一个用于拦截android实时短信的库,可以进行短信过滤,得到自己想要的内容,可以用于需要自动填写短信验证码的app项目
- Android源码编译和APP编译步骤
- android 通过链接打开自己的app
- 解析Android APP如何防止被反编译
- 自己编译Android gdbserver(解决运行 gdbserver时 Segmentation fault 问题)