Ying Wang | 7311a34 | 2013-08-21 18:32:49 -0700 | [diff] [blame] | 1 | # We have moved -dontobfuscate and -dontoptimize to the makefiles. |
Ying Wang | 3b2bdf1 | 2010-02-01 09:51:23 -0800 | [diff] [blame] | 2 | # dex does not like code run through proguard optimize and preverify steps. |
Ying Wang | 7311a34 | 2013-08-21 18:32:49 -0700 | [diff] [blame] | 3 | # -dontoptimize |
Ying Wang | 3b2bdf1 | 2010-02-01 09:51:23 -0800 | [diff] [blame] | 4 | -dontpreverify |
| 5 | |
| 6 | # Don't obfuscate. We only need dead code striping. |
Ying Wang | 7311a34 | 2013-08-21 18:32:49 -0700 | [diff] [blame] | 7 | # -dontobfuscate |
Ying Wang | 3b2bdf1 | 2010-02-01 09:51:23 -0800 | [diff] [blame] | 8 | |
| 9 | # Add this flag in your package's own configuration if it's needed. |
| 10 | #-flattenpackagehierarchy |
| 11 | |
Jared Duke | 97a9903 | 2022-08-02 16:05:03 -0700 | [diff] [blame^] | 12 | # Keep classes and methods that have @VisibleForTesting annotations, except in |
| 13 | # intermediate libraries that export those annotations (e.g., androidx, guava). |
| 14 | # This avoids keeping library-specific test code that isn't actually needed |
| 15 | # for platform testing. |
| 16 | # TODO(b/239961360): Migrate away from androidx.annotation.VisibleForTesting |
| 17 | # and com.google.common.annotations.VisibleForTesting use in platform code. |
| 18 | -keep @**.VisibleForTesting class !androidx.**,!com.google.common.**,* |
| 19 | -keepclassmembers class !androidx.**,!com.google.common.**,* { |
| 20 | @**.VisibleForTesting *; |
Ying Wang | 38cdd44 | 2013-05-30 10:45:46 -0700 | [diff] [blame] | 21 | } |
Ying Wang | 3b2bdf1 | 2010-02-01 09:51:23 -0800 | [diff] [blame] | 22 | |
Jared Duke | 7d0c90b | 2022-05-09 18:09:01 -0700 | [diff] [blame] | 23 | # Keep rule for members that are needed solely to keep alive downstream weak |
| 24 | # references, and could otherwise be removed after tree shaking optimizations. |
| 25 | -keepclassmembers,allowaccessmodification,allowobfuscation,allowshrinking class * { |
| 26 | @com.android.internal.annotations.KeepForWeakReference <fields>; |
| 27 | } |
| 28 | |
Jared Duke | 4bd749b | 2021-12-14 15:28:33 -0800 | [diff] [blame] | 29 | # Understand the common @Keep annotation from various Android packages: |
| 30 | # * android.support.annotation |
| 31 | # * androidx.annotation |
| 32 | # * com.android.internal.annotations |
| 33 | -keep class **android**.annotation*.Keep |
Colin Cross | 38b48de | 2019-03-26 09:48:28 -0700 | [diff] [blame] | 34 | |
Jared Duke | 4bd749b | 2021-12-14 15:28:33 -0800 | [diff] [blame] | 35 | -keep @**android**.annotation*.Keep class * { *; } |
Colin Cross | 38b48de | 2019-03-26 09:48:28 -0700 | [diff] [blame] | 36 | |
| 37 | -keepclasseswithmembers class * { |
Jared Duke | 4bd749b | 2021-12-14 15:28:33 -0800 | [diff] [blame] | 38 | @**android**.annotation*.Keep <methods>; |
Colin Cross | 38b48de | 2019-03-26 09:48:28 -0700 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | -keepclasseswithmembers class * { |
Jared Duke | 4bd749b | 2021-12-14 15:28:33 -0800 | [diff] [blame] | 42 | @**android**.annotation*.Keep <fields>; |
Colin Cross | 38b48de | 2019-03-26 09:48:28 -0700 | [diff] [blame] | 43 | } |
| 44 | |
| 45 | -keepclasseswithmembers class * { |
Jared Duke | 4bd749b | 2021-12-14 15:28:33 -0800 | [diff] [blame] | 46 | @**android**.annotation*.Keep <init>(...); |
Colin Cross | 38b48de | 2019-03-26 09:48:28 -0700 | [diff] [blame] | 47 | } |
| 48 | |
Ying Wang | 5745351 | 2013-05-17 10:02:00 -0700 | [diff] [blame] | 49 | -include proguard_basic_keeps.flags |