I am trying to add the Jackson JSON library to my AOSP project. I am able to compile my project and flash it to a phone, but I get a runtime error:
E/JavaBinder(
To include a 3rd party library from source:
$ANDROID_BUILD_TOP/external/
(ex: $ANDROID_BUILD_TOP/external/jackson
)Create an Android.mk
file, and place it in the library's folder (ex: $ANDROID_BUILD_TOP/external/jackson/Android.mk
Contents of Android.mk:
# required (setup the build environment)
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
# optional step to automate some pre-compilation steps for this library
# run `mvn generate-sources` before we compile
$(info $(shell (mvn generate-sources -f $(LOCAL_PATH)/pom.xml)))
# required (the name of the library we are building)
LOCAL_MODULE := jackson
# required (paths to all directories that include source code)
# note the difference between the := (first line) and += (every other line)
LOCAL_SRC_FILES := $(call all-java-files-under, src/main)
LOCAL_SRC_FILES += $(call all-java-files-under, target/generated-sources)
# required (tell the build system what kind of thing we are building)
include $(BUILD_JAVA_LIBRARY)
Add the library to the PRODUCT_BOOT_JARS
section of your mk
file. Which file you edit depends on what you are building (ex: build/target/product/core_minimal.mk
)
Original
PRODUCT_BOOT_JARS := \
okhttp \
core-junit \
bouncycastle \
ext \
gson
Modified
PRODUCT_BOOT_JARS := \
okhttp \
core-junit \
bouncycastle \
ext \
gson \
jackson
For each submodule of your AOSP project (ex: frameworks/base
), that you want to have access to the library, find the makefile (ex: $ANDROID_BUILD_TOP/frameworks/base/Android.mk
and add an entry for your library to the LOCAL_JAVA_LIBRARIES
line. Example:
Original
LOCAL_JAVA_LIBRARIES := guice gson
Modified
LOCAL_JAVA_LIBRARIES := guice gson jackson
Compile your project.