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
This commit is contained in:
Colin Cross 2018-05-25 11:28:37 -07:00
parent e2d0b0cc43
commit cf5180c198
1 changed files with 3 additions and 0 deletions

View File

@ -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