将外部JAR添加到Android AOSP构建时出错

时间:2018-01-30 23:08:40

标签: android makefile android-source

我正在尝试将外部JAR文件(例如,gson或eventbus)添加到我的AOSP构建中。我尝试了两种不同的方式:

  • 将它们添加到prebuilts/misc/common/mylibs/并为目录创建Android.mk文件。然后,我只在我的应用程序的Android.mk文件中包含lib的符号名称。

  • 在我的自定义应用源代码的子目录libs中添加它们,并直接通过应用的Android.mk文件添加它。

然而,这两种方法都产生了类似的错误,第二种方法如下:

ninja: error: 'packages/apps/Car/MyApp/packages/apps/Car/Myapp/libs/gson-2.6.2.jar', needed by 'out/target/common/obj/JAVA_LIBRARIES/gson_intermediate/classes.jack', missing and no known rule to make it.

我注意到错误消息中的奇怪重复路径。有人知道我做错了什么吗?

这是第二种方式的Android.mk文件:

LOCAL_PATH:= $(call my-dir)

include $(CLEAR_VARS)

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

LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res

LOCAL_PACKAGE_NAME := MyApp

LOCAL_CERTIFICATE := platform

LOCAL_MODULE_TAGS := optional

LOCAL_PRIVILEGED_MODULE := true

LOCAL_STATIC_JAVA_LIBRARIES += jsr305 gson

LOCAL_STATIC_ANDROID_LIBRARIES := android-support-v4

LOCAL_USE_AAPT2 := true

include packages/apps/Car/libs/car-stream-ui-lib/car-stream-ui-lib.mk
include packages/services/Car/car-support-lib/car-support.mk

include $(BUILD_PACKAGE)

include $(CLEAR_VARS)
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := gson:$(LOCAL_PATH)/libs/gson-2.6.2.jar
include $(BUILD_MULTI_PREBUILT)

1 个答案:

答案 0 :(得分:1)

从路径中删除$(LOCAL_PATH)