1# Keep classes and members with the platform-defined @VisibleForTesting annotation. 2-keep @com.android.internal.annotations.VisibleForTesting class * 3-keepclassmembers class * { 4 @com.android.internal.annotations.VisibleForTesting *; 5} 6 7# Keep classes and members with platform @TestApi annotations, similar to 8# @VisibleForTesting. 9-keep @android.annotation.TestApi class * 10-keepclassmembers class * { 11 @android.annotation.TestApi *; 12} 13 14# Keep classes and members with non-platform @VisibleForTesting annotations, but 15# only within platform-defined packages. This avoids keeping external, library-specific 16# test code that isn't actually needed for platform testing. 17# TODO(b/239961360): Migrate away from androidx.annotation.VisibleForTesting 18# and com.google.common.annotations.VisibleForTesting use in platform code. 19-keep @**.VisibleForTesting class android.**,com.android.**,com.google.android.** 20-keepclassmembers class android.**,com.android.**,com.google.android.** { 21 @**.VisibleForTesting *; 22} 23 24# Keep rule for members that are needed solely to keep alive downstream weak 25# references, and could otherwise be removed after tree shaking optimizations. 26-keepclassmembers,allowaccessmodification,allowobfuscation,allowshrinking class * { 27 @com.android.internal.annotations.KeepForWeakReference <fields>; 28} 29 30# Needed to ensure callback field references are kept in their respective 31# owning classes when the downstream callback registrars only store weak refs. 32-if @com.android.internal.annotations.WeaklyReferencedCallback class * 33-keepclassmembers,allowaccessmodification,allowobfuscation,allowshrinking class * { 34 !synthetic <1> *; 35} 36-if class * extends @com.android.internal.annotations.WeaklyReferencedCallback ** 37-keepclassmembers,allowaccessmodification,allowobfuscation,allowshrinking class * { 38 !synthetic <1> *; 39} 40 41# Understand the common @Keep annotation from various Android packages: 42# * android.support.annotation 43# * androidx.annotation 44# * com.android.internal.annotations 45-keep class **android**.annotation*.Keep 46 47-keep @**android**.annotation*.Keep class * { *; } 48 49-keepclasseswithmembers class * { 50 @**android**.annotation*.Keep <methods>; 51} 52 53-keepclasseswithmembers class * { 54 @**android**.annotation*.Keep <fields>; 55} 56 57-keepclasseswithmembers class * { 58 @**android**.annotation*.Keep <init>(...); 59} 60 61# Keep Dalvik optimization annotations. These annotations are special in that 62# 1) we want them preserved for visibility with ART, but 2) they don't have 63# RUNTIME retention. These minimal keep rules ensure they're not stripped by R8. 64# TODO(b/215417388): Export this rule from the owning library, core-libart, 65# via export_proguard_flags_files. 66-keepclassmembers,allowshrinking,allowoptimization,allowobfuscation,allowaccessmodification class * { 67 @dalvik.annotation.optimization.** *; 68} 69 70-include proguard_basic_keeps.flags 71-include proguard/kotlin.flags 72