android编译源码+在源码中build工程方法(紧支持jdk1.5)

编译源码:

          1、打开终端,进入源码文件夹。例如:/root/android2.2/

          2、输入命令  . build/envsetup.sh(运行脚本文件)

          3、输入命令  make -j 4  开始编译

build工程:

          1、将需要编译的工程放入/源码根目录/packages/app/下 ,例如:/root/android2.2/packages/app/Hello,在Hello中创建Android.mk文件 ,内容如下:(具体内容自己修改)

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

LOCAL_MODULE_TAGS := optional

LOCAL_STATIC_JAVA_LIBRARIES := \
        android-common \
	protobuf-java-2.3.0-lite \
	maps

LOCAL_SRC_FILES := \
        $(call all-java-files-under, src)

LOCAL_PACKAGE_NAME := Hello

include $(BUILD_PACKAGE)

# additionally, build tests in sub-folders in a separate .apk
include $(call all-makefiles-under,$(LOCAL_PATH))

###############################
include $(CLEAR_VARS) 
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := protobuf-java-2.3.0-lite:libs/protobuf-java-2.3.0-lite.jar maps:libs/maps.jar
include $(BUILD_MULTI_PREBUILT)
############################### 
其中要修改的是LOCAL_STATIC_JAVA_LIBRARIES你所要用的包      LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES包的映射路径    LOCAL_PACKAGE_NAME

          2、打开终端,进入到工程文件夹内,例如:root@ubuntu:~/android2.2/packages/apps/Hello#

          3、执行mm,如不能运行,请先执行      . ../../../build/envsetup.sh     运行脚本,再次执行mm

          4、如第3部不能执行,可以进入 /root/源码根目录/,例如:/root/android2.2/下,执行make Hello(Hello为工程名)

注意:在第一次build之前要编译下源码,之后就不用了

android2.3之后 ,编译需要jdk1.6


你可能感兴趣的:(java,jdk,android,脚本,Build,Path)