aboutsummaryrefslogtreecommitdiff
path: root/core/proguard.flags
blob: aa406b983e973ebf3939931d80d0b3bac4bdeb35 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# We have moved -dontobfuscate and -dontoptimize to the makefiles.
# dex does not like code run through proguard optimize and preverify steps.
# -dontoptimize
-dontpreverify

# Don't obfuscate. We only need dead code striping.
# -dontobfuscate

# Add this flag in your package's own configuration if it's needed.
#-flattenpackagehierarchy

# Keep classes and members with the platform-defined @VisibleForTesting annotation.
-keep @com.android.internal.annotations.VisibleForTesting class *
-keepclassmembers class * {
    @com.android.internal.annotations.VisibleForTesting *;
}

# Keep classes and members with platform @TestApi annotations, similar to
# @VisibleForTesting.
-keep @android.annotation.TestApi class *
-keepclassmembers class * {
    @android.annotation.TestApi *;
}

# Keep classes and members with non-platform @VisibleForTesting annotations, but
# only within platform-defined packages. This avoids keeping external, library-specific
# test code that isn't actually needed for platform testing.
# TODO(b/239961360): Migrate away from androidx.annotation.VisibleForTesting
# and com.google.common.annotations.VisibleForTesting use in platform code.
-keep @**.VisibleForTesting class android.**,com.android.**,com.google.android.**
-keepclassmembers class android.**,com.android.**,com.google.android.** {
    @**.VisibleForTesting *;
}

# Keep rule for members that are needed solely to keep alive downstream weak
# references, and could otherwise be removed after tree shaking optimizations.
-keepclassmembers,allowaccessmodification,allowobfuscation,allowshrinking class * {
  @com.android.internal.annotations.KeepForWeakReference <fields>;
}

# 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**.annotation*.Keep class * { *; }

-keepclasseswithmembers class * {
    @**android**.annotation*.Keep <methods>;
}

-keepclasseswithmembers class * {
    @**android**.annotation*.Keep <fields>;
}

-keepclasseswithmembers class * {
    @**android**.annotation*.Keep <init>(...);
}

# Keep Dalvik optimization annotations. These annotations are special in that
# 1) we want them preserved for visibility with ART, but 2) they don't have
# RUNTIME retention. These minimal keep rules ensure they're not stripped by R8.
# TODO(b/215417388): Export this rule from the owning library, core-libart,
# via export_proguard_flags_files.
-keepclassmembers,allowshrinking,allowoptimization,allowobfuscation,allowaccessmodification class * {
    @dalvik.annotation.optimization.** *;
}

-include proguard_basic_keeps.flags
-include proguard/kotlin.flags