diff --git a/core/definitions.mk b/core/definitions.mk index 86bda9ea5..8d9f7f5e8 100644 --- a/core/definitions.mk +++ b/core/definitions.mk @@ -2692,6 +2692,17 @@ define add-carried-jack-resources fi endef +# Add resources (non .class files) from a jar to a package +# $(1): the package file +# $(2): the jar file +# $(3): temporary directory +define add-jar-resources-to-package + rm -rf $(3) + mkdir -p $(3) + unzip -qo $(2) -d $(3) $$(zipinfo -1 $(2) | grep -v -E "\.class$$") + $(JAR) uf $(1) -C $(3) . +endef + # Sign a package using the specified key/cert. # define sign-package diff --git a/core/package_internal.mk b/core/package_internal.mk index 74dd15ed5..c4a0d622f 100644 --- a/core/package_internal.mk +++ b/core/package_internal.mk @@ -563,7 +563,10 @@ else $(my_res_package) $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_PREF_CONFIG := $(PRODUCT_AAPT_PREF_CONFIG) endif endif + $(LOCAL_BUILT_MODULE): PRIVATE_DONT_DELETE_JAR_DIRS := $(LOCAL_DONT_DELETE_JAR_DIRS) +$(LOCAL_BUILT_MODULE): PRIVATE_RESOURCE_INTERMEDIATES_DIR := $(intermediates.COMMON)/resources +$(LOCAL_BUILT_MODULE): PRIVATE_FULL_CLASSES_JAR := $(full_classes_jar) $(LOCAL_BUILT_MODULE) : $(jni_shared_libraries) ifdef LOCAL_USE_AAPT2 $(LOCAL_BUILT_MODULE): PRIVATE_RES_PACKAGE := $(my_res_package) @@ -592,6 +595,11 @@ ifeq ($(full_classes_jar),) $(if $(PRIVATE_EXTRA_JAR_ARGS),$(call add-java-resources-to,$@)) else # full_classes_jar $(add-dex-to-package) +ifdef LOCAL_USE_AAPT2 +ifndef LOCAL_JACK_ENABLED + $(call add-jar-resources-to-package,$@,$(PRIVATE_FULL_CLASSES_JAR),$(PRIVATE_RESOURCE_INTERMEDIATES_DIR)) +endif +endif endif # full_classes_jar ifdef LOCAL_JACK_ENABLED $(add-carried-jack-resources)