具体代码如下:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_STATIC_JAVA_LIBRARIES := libarity
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_PACKAGE_NAME := TestJar
include $(BUILD_PACKAGE)
##################################################
include $(CLEAR_VARS)
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := libarity:lily.jar
include $(BUILD_MULTI_PREBUILT)
# Use the folloing include to make our test apk.
include $(call all-makefiles-under,$(LOCAL_PATH))
关键在于LOCAL_STATIC_JAVA_LIBRARIES := libarity和LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := libarity:lily.jar
其实libarity是个名字可以随便取,但是两个属性的值要一样就好了,但是后面那个冒号里面就一定要写你的jar包名,你的jar包一定放在工程的根目录就好了,目录结构如下:
-res
-src
-com
-ianc
-testjar
TestJar.java
android.mk
AndroidManifest.xml
default.properties
lily.jar