Thursday, March 27, 2014

create static JAVA lib jar for other APK reference

static_java_library 和 java_library不同點:
1. java_library 編譯完會output到 ANDROID_ROOT/out/target/product/generic/system/framework,而static_java_library不會。
2. 當APK reference到java_library時,不會把jar source編譯進APK。但是static_java_library會編譯進去, 所以執行該APK的機器不需要有static_java_library存在。
3. 編譯兩種library的方法一樣,只差在make file

Make file example:

ifneq ($(TARGET_BUILD_JAVA_SUPPORT_LEVEL),)
LOCAL_PATH := $(call my-dir)
# the library
# ============================================================
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(call all-subdir-java-files)
LOCAL_MODULE_TAGS := optional
# This is the target being built.
LOCAL_MODULE:= com.mylib.staticlibrary
include $(BUILD_STATIC_JAVA_LIBRARY)
# the documentation
# ============================================================
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(call all-subdir-java-files) $(call all-subdir-html-files)
LOCAL_MODULE:= mystaticlibraryDoc
LOCAL_DROIDDOC_OPTIONS := com.mylib.staticlibrary
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
LOCAL_DROIDDOC_USE_STANDARD_DOCLET := true
include $(BUILD_DROIDDOC)
endif # JAVA_SUPPORT

No comments:

Post a Comment