compile/link prebuilt nonstatic java library failed?

Hi all,
Did you know how to use a prebuilt nonstatic java library in framework.
I compile a nonstatic java library first use

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

LOCAL_SRC_FILES := \
$(call all-subdir-java-files, ./src)

LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := mylib
LOCAL_NO_STANDARD_LIBRARIES := true
LOCAL_JAVA_LIBRARIES := core core-junit ext

include $(BUILD_JAVA_LIBRARY)

because it's nonstatic java library, so
under out/target/common/obj/JAVA_LIBRARIES/mylib_intermediates/javalib.jar
contain classes.dex.
I want to release mylib.jar binary, and framework.jar depends on it, so in
framework android.mk I add LOCAL_JAVA_LIBRARIES := mylib
and prebuilt mylib android.mk is like:


LOCAL_PATH := $(PREBUILT_PATH)
include $(CLEAR_VARS)
LOCAL_MODULE := mylib
LOCAL_MODULE_TAGS := optional eng
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
LOCAL_MODULE_SUFFIX := $(COMMON_JAVA_PACKAGE_SUFFIX)
LOCAL_SRC_FILES :=
../../.././target/common/obj/JAVA_LIBRARIES/mylib_intermediates/javalib.jar
include $(BUILD_PREBUILT)

Now I meet a link error, framework can't find the package in mylib.jar
I read build/core/prebuilt.mk got some infos:

ifeq ($(LOCAL_IS_HOST_MODULE)$(LOCAL_MODULE_CLASS),JAVA_LIBRARIES)
# for target java libraries, the LOCAL_BUILT_MODULE is in a
product-specific dir,
# while the deps should be in the common dir, so we make a copy in the
common dir.
# For nonstatic library, $(common_javalib_jar) is the dependency file,
# while $(common_classes_jar) is used to link.
common_classes_jar := $(call
intermediates-dir-for,JAVA_LIBRARIES,$(LOCAL_MODULE),,COMMON)/classes.jar
common_javalib_jar := $(dir $(common_classes_jar))javalib.jar

$(common_classes_jar) : $(LOCAL_PATH)/$(LOCAL_SRC_FILES) | $(ACP)
$(transform-prebuilt-to-target)

$(common_javalib_jar) : $(common_classes_jar) | $(ACP)
$(transform-prebuilt-to-target)

# make sure the classes.jar and javalib.jar are built before
$(LOCAL_BUILT_MODULE)
$(built_module) : $(common_javalib_jar)
endif # TARGET JAVA_LIBRARIES


it said that for nonstatic library, $(common_javalib_jar) is the dependency
file, while $(common_classes_jar) is used to link.
the issue is that nonstaitc java lib (javalib.jar) only have classes.dex,
but the prebuilt.mk just cp javalib.jar --> classes.jar then
classes.jar-->javalib.jar, the classes.jar == javalib.jar
it seems nonstatic java lib can't use include $(BUILD_PREBUILT) maybe it's
a bug in prebuilt. Can anybody help me about this, or answer me if android
build system support prebuilt nonstatic java lib and depended by other lib
like framework.jar? if support, what should I do? Thanks

你可能感兴趣的:(compile/link prebuilt nonstatic java library failed?)