Search code examples
javaandroidandroid-sourceandroid.mk

Unknown package name of class file


I have two libraries that I want to add to AOSP: Azure Storage & Jackson Core

When Azure Storage depends on Jackson.

Following this instructions, I've added both of them under [MAIN_FOLDER]/external and with the following Android.mk files:

For Jackson -

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

LOCAL_MODULE := jackson

LOCAL_MODULE_TAGS := eng debug optional

LOCAL_SDK_VERSION := current

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

include $(BUILD_JAVA_LIBRARY)

and for Azure storage -

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

LOCAL_MODULE := azure-storage

LOCAL_JAVA_LIBRARIES := jackson

LOCAL_MODULE_TAGS := eng debug optional

LOCAL_SDK_VERSION := current

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

include $(BUILD_JAVA_LIBRARY)

When I also added:

PRODUCT_BOOT_JARS := \
    jackson \
    azure-storage

to my core_minimal.mk.

and the following to [MAIN_FOLDER]/frameworks/base/services/core/Android.mk:

LOCAL_JAVA_LIBRARIES += jackson azure-storage

Alas, when I try to make update-api && make, I get the following error:

Error: out/target/common/obj/JAVA_LIBRARIES/jackson_intermediates/classes.jar: unknown package name of class file com/fasterxml/jackson/core/JsonLocation.class

Error: out/target/common/obj/JAVA_LIBRARIES/azure-storage_intermediates/classes.jar: unknown package name of class file com/microsoft/azure/storage/CorsRule.class

make: *** [out/target/common/obj/PACKAGING/boot-jars-package-check_intermediates/stamp] Error 1

make: *** Waiting for unfinished jobs....

Thanks!


Solution

  • First, we'd better find where this error comes from, with 'grep' we found it comes from a Python: build/core/tasks/check_boot_jars/check_boot_jars.py:

    def CheckJar(jar):
    package_name = os.path.dirname(f)
    package_name = package_name.replace('/', '.')
    # Skip class without a package name
    if package_name and not whitelist_re.match(package_name):
        print >> sys.stderr, ('Error: %s: unknown package name of class file %s' % (jar, f))
        return False
    

    Apparently, if your package name not exists in "whitelist_re", you got the error!

    "whitelist_re"'s values come from a txt file named "build/core/tasks/check_boot_jars/package_whitelist.txt", so the solution is add your package to this whitelist file.

    Examples are listed in package_whitelist.txt.