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

人生处万类,知识最为贤。这篇文章主要讲述将外部JAR添加到Android AOSP构建时出错相关的知识,希望能为你提供帮助。
我正在尝试将外部JAR文件(例如,gson或eventbus)添加到我的AOSP构建中。我尝试了两种不同的方式:

  • 将它们添加到prebuilts/misc/common/mylibs/并为dir创建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)/resLOCAL_PACKAGE_NAME := MyAppLOCAL_CERTIFICATE := platformLOCAL_MODULE_TAGS := optionalLOCAL_PRIVILEGED_MODULE := trueLOCAL_STATIC_JAVA_LIBRARIES += jsr305 gsonLOCAL_STATIC_ANDROID_LIBRARIES := android-support-v4LOCAL_USE_AAPT2 := trueinclude packages/apps/Car/libs/car-stream-ui-lib/car-stream-ui-lib.mk include packages/services/Car/car-support-lib/car-support.mkinclude $(BUILD_PACKAGE)include $(CLEAR_VARS) LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := gson:$(LOCAL_PATH)/libs/gson-2.6.2.jar include $(BUILD_MULTI_PREBUILT)

答案【将外部JAR添加到Android AOSP构建时出错】从修复它的路径中删除$(LOCAL_PATH)

    推荐阅读