From 4bd749bf383dc3a508166e3d152b5e71b11b7789 Mon Sep 17 00:00:00 2001 From: Jared Duke Date: Tue, 14 Dec 2021 15:28:33 -0800 Subject: [PATCH] Generalize @Keep annotation Proguard rules Consolidate the Proguard rules for @Keep annotations for: * android.support.annotation.Keep (existing) * androidx.annotation.Keep (existing) * com.android.internal.annotation.Keep (new) This ensures consistent semantics for clients using these annotations across the codebase. Ideally there would be a single annotation, but the support libraries are not available everywhere. In practice, this change should be a no-op. Bug: 210510433 Test: m + validate identical artifact sizes Change-Id: Iab494e03269e5758d7f860331e971826ecc08cdd --- core/proguard.flags | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/core/proguard.flags b/core/proguard.flags index 50049cbdad..185275e858 100644 --- a/core/proguard.flags +++ b/core/proguard.flags @@ -15,35 +15,24 @@ @**.VisibleForTesting *; } -# Understand the @Keep support annotation. --keep class android.support.annotation.Keep --keep class androidx.annotation.Keep +# Understand the common @Keep annotation from various Android packages: +# * android.support.annotation +# * androidx.annotation +# * com.android.internal.annotations +-keep class **android**.annotation*.Keep --keep @android.support.annotation.Keep class * {*;} --keep @androidx.annotation.Keep class * {*;} +-keep @**android**.annotation*.Keep class * { *; } -keepclasseswithmembers class * { - @android.support.annotation.Keep ; + @**android**.annotation*.Keep ; } -keepclasseswithmembers class * { - @androidx.annotation.Keep ; + @**android**.annotation*.Keep ; } -keepclasseswithmembers class * { - @android.support.annotation.Keep ; -} - --keepclasseswithmembers class * { - @androidx.annotation.Keep ; -} - --keepclasseswithmembers class * { - @android.support.annotation.Keep (...); -} - --keepclasseswithmembers class * { - @androidx.annotation.Keep (...); + @**android**.annotation*.Keep (...); } -include proguard_basic_keeps.flags