From cf5180c19849638a1c396e72603888ca43c7b152 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Fri, 25 May 2018 11:28:37 -0700 Subject: [PATCH 1/2] Work around incorrect R8 proguard compatibility Proguard treats -dontobfuscate -keepattributes *Annotations* the same as -dontobufscate by keeping all attributes. R8, even in proguard compatibility mode, discards all attributes that don't match, including EnclosingClass attributes that may be necessary. Pass -keepattributes * whenever passing -dontobfuscate to make R8 act more like proguard. This isn't a complete solution, some modules may set LOCAL_PROGUARD_ENABLED := custom and then manually specify -dontobfuscate on the command line or in a flags file, in which case they will see the incorrect behavior of R8. Bug: 80081393 Test: m checkbuild Test: examine attributes on com.android.stk.BootCompletedReceiver in out/target/common/obj/APPS/Stk_intermediates/classes.dex Change-Id: I761f2d0617c5295df8fc7adfc4fd00d2aa41961e --- core/java.mk | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/java.mk b/core/java.mk index 8e5fd1df8..c6b4ffb25 100644 --- a/core/java.mk +++ b/core/java.mk @@ -458,6 +458,9 @@ endif ifeq ($(filter obfuscation,$(LOCAL_PROGUARD_ENABLED)),) # By default no obfuscation common_proguard_flags += -dontobfuscate +# Workaround for b/80081393: R8 discards other attributes when +# -keepattributes *Annotations* is used, even when obfuscation is off. +common_proguard_flags += -keepattributes '*' endif # No obfuscation ifeq ($(filter optimization,$(LOCAL_PROGUARD_ENABLED)),) # By default no optimization From 5b89ec4d4250fae0489fb55b13f8b61561a168bd Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Wed, 23 May 2018 17:20:58 +0000 Subject: [PATCH 2/2] Revert "Revert "Use AAPT2 by default"" This reverts commit 777cf2c450bfa5ff2af4214647d54b095a8f19c4. Reason for revert: manifest merger is used for libraries forced to aapt2 now Bug: 79481102 Test: m checkbuild Change-Id: I9b67fd2a9b3234798b2aac879b5242c2097b3863 --- core/force_aapt2.mk | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core/force_aapt2.mk b/core/force_aapt2.mk index a097bd2f3..ede6fd490 100644 --- a/core/force_aapt2.mk +++ b/core/force_aapt2.mk @@ -17,7 +17,7 @@ # Including this makefile will force AAPT2 on if FORCE_AAPT2==true, # rewriting some properties to convert standard AAPT usage to AAPT2. -ifeq ($(FORCE_AAPT2),true) +ifneq ($(FORCE_AAPT2),false) ifeq ($(LOCAL_USE_AAPT2),) # Force AAPT2 on LOCAL_USE_AAPT2 := true @@ -47,7 +47,6 @@ ifeq ($(FORCE_AAPT2),true) ifeq (,$(strip $(LOCAL_MANIFEST_FILE)$(LOCAL_FULL_MANIFEST_FILE))) ifeq (,$(wildcard $(LOCAL_PATH)/AndroidManifest.xml)) # work around missing manifests by creating a default one - $(call pretty-warning, Missing manifest file) LOCAL_FULL_MANIFEST_FILE := $(call local-intermediates-dir,COMMON)/DefaultManifest.xml ifdef LOCAL_MIN_SDK_VERSION my_manifest_min_sdk_version := $(LOCAL_MIN_SDK_VERSION)