From b5f25a257f39293ee372025fc70e602724d0c47f Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Fri, 20 Oct 2017 19:16:41 -0700 Subject: [PATCH] Always raise proguard libraries The platform build system doesn't have the concept of a "compile sdk version", it uses the "min sdk version" throughout the compilation process. This means that no stage of the compilation process can introduce references to APIs that do not exist in the selected LOCAL_MIN_SDK_VERSION without causing problems. Support library worked around this by effectively making the "compile sdk version" "current" when running proguard if support library was in the direct dependency list. Extend the support library hack everywhere, and always use "current" or the full bootclasspath when running proguard. Test: m checkbuild Change-Id: Iaf5853361767f0ea3e9ad4ec908aadd72d639c79 --- core/java.mk | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/core/java.mk b/core/java.mk index 7584479ef..59169fff6 100644 --- a/core/java.mk +++ b/core/java.mk @@ -605,33 +605,33 @@ ifneq ($(filter-out full custom nosystem obfuscation optimization shrinktests,$( endif proguard_dictionary := $(intermediates.COMMON)/proguard_dictionary -# Hack: see b/20667396 -# When an app's LOCAL_SDK_VERSION is lower than the support library's LOCAL_SDK_VERSION, -# we artifically raises the "SDK version" "linked" by ProGuard, to +# When an app contains references to APIs that are not in the SDK specified by +# its LOCAL_SDK_VERSION for example added by support library or by runtime +# classes added by desugar, we artifically raise the "SDK version" "linked" by +# ProGuard, to # - suppress ProGuard warnings of referencing symbols unknown to the lower SDK version. # - prevent ProGuard stripping subclass in the support library that extends class added in the higher SDK version. -my_support_library_sdk_raise := -ifneq (,$(filter android-support-%,$(LOCAL_STATIC_JAVA_LIBRARIES))) +# See b/20667396 +my_proguard_sdk_raise := ifdef LOCAL_SDK_VERSION ifdef TARGET_BUILD_APPS ifeq (,$(filter current system_current test_current, $(LOCAL_SDK_VERSION))) - my_support_library_sdk_raise := $(call java-lib-header-files, sdk_vcurrent) + my_proguard_sdk_raise := $(call java-lib-header-files, sdk_vcurrent) endif else # For platform build, we can't just raise to the "current" SDK, # that would break apps that use APIs removed from the current SDK. - my_support_library_sdk_raise := $(call java-lib-header-files,$(TARGET_DEFAULT_BOOTCLASSPATH_LIBRARIES) $(TARGET_DEFAULT_JAVA_LIBRARIES)) -endif + my_proguard_sdk_raise := $(call java-lib-header-files,$(TARGET_DEFAULT_BOOTCLASSPATH_LIBRARIES) $(TARGET_DEFAULT_JAVA_LIBRARIES)) endif endif -legacy_proguard_flags := $(addprefix -libraryjars ,$(my_support_library_sdk_raise) \ - $(filter-out $(my_support_library_sdk_raise), \ +legacy_proguard_flags := $(addprefix -libraryjars ,$(my_proguard_sdk_raise) \ + $(filter-out $(my_proguard_sdk_raise), \ $(full_java_bootclasspath_libs) \ $(full_shared_java_header_libs))) -legacy_proguard_lib_deps := $(my_support_library_sdk_raise) \ - $(filter-out $(my_support_library_sdk_raise),$(full_shared_java_header_libs)) +legacy_proguard_lib_deps := $(my_proguard_sdk_raise) \ + $(filter-out $(my_proguard_sdk_raise),$(full_shared_java_header_libs)) legacy_proguard_flags += -printmapping $(proguard_dictionary) @@ -721,7 +721,7 @@ endif $(full_classes_proguard_jar): PRIVATE_PROGUARD_INJAR_FILTERS := $(proguard_injar_filters) $(full_classes_proguard_jar): PRIVATE_EXTRA_INPUT_JAR := $(extra_input_jar) $(full_classes_proguard_jar): PRIVATE_PROGUARD_FLAGS := $(legacy_proguard_flags) $(common_proguard_flags) $(LOCAL_PROGUARD_FLAGS) -$(full_classes_proguard_jar) : $(full_classes_pre_proguard_jar) $(extra_input_jar) $(my_support_library_sdk_raise) $(common_proguard_flag_files) $(proguard_flag_files) $(legacy_proguard_lib_deps) | $(PROGUARD) +$(full_classes_proguard_jar) : $(full_classes_pre_proguard_jar) $(extra_input_jar) $(my_proguard_sdk_raise) $(common_proguard_flag_files) $(proguard_flag_files) $(legacy_proguard_lib_deps) | $(PROGUARD) $(call transform-jar-to-proguard) else # LOCAL_PROGUARD_ENABLED not defined