Unknown package name of class file

北战南征 提交于 2020-01-04 05:37:08

问题


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!


回答1:


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.




回答2:


Apparently all libraries have to start with com.android.,

so I've added jarjar-rules.txt with the following:

rule com.microsoft.** com.android.@0
rule com.fasterxml.** com.android.@0

and added the following line to Android.mk:

LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt

Now, all the references to com.microsoft.azure.storage.* should be changed to com.android.com.microsoft.azure.storage.* and the same for fasterxml.



来源:https://stackoverflow.com/questions/40114369/unknown-package-name-of-class-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!