1# Copyright 2016 The Chromium Authors 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5# Contains //base flags that we'd like all Chromium .apks to use. Note that 6# these rules will not be applied to Chromium code that ships in third-party 7# APKs, e.g. Cronet. 8 9# Keep line number information, useful for stack traces. 10-keepattributes SourceFile,LineNumberTable 11 12# Enable protobuf-related optimizations. 13-shrinkunusedprotofields 14 15# Allowing Proguard to change modifiers. 16-allowaccessmodification 17 18# Keep all CREATOR fields within Parcelable that are kept. 19-keepclassmembers class !cr_allowunused,** implements android.os.Parcelable { 20 public static *** CREATOR; 21} 22 23# Don't obfuscate Parcelables as they might be marshalled outside Chrome. 24# If we annotated all Parcelables that get put into Bundles other than 25# for saveInstanceState (e.g. PendingIntents), then we could actually keep the 26# names of just those ones. For now, we'll just keep them all. 27-keepnames,allowaccessmodification class !cr_allowunused,** implements android.os.Parcelable {} 28 29# Keep all default constructors for used Fragments. Required since they are 30# called reflectively when fragments are reinflated after the app is killed. 31-keepclassmembers class !cr_allowunused,** extends android.app.Fragment { 32 public <init>(); 33} 34-keepclassmembers class !cr_allowunused,** extends androidx.fragment.app.Fragment { 35 public <init>(); 36} 37 38# This is to workaround crbug.com/1204690 - an old GMS app version crashes when 39# ObjectWrapper contains > 1 fields, and this prevents R8 from inserting a 40# synthetic field. 41-keep,allowaccessmodification class !cr_allowunused,com.google.android.gms.dynamic.ObjectWrapper { 42 <fields>; 43} 44 45# Remove calls to String.format() where the result goes unused. This can mask 46# exceptions if the parameters to String.format() are invalid, but such cases 47# are generally programming bugs anyways. 48# Not using the return value generally occurs due to logging being stripped. 49-assumenosideeffects class java.lang.String { 50 static java.lang.String format(...); 51} 52 53# Allows R8 to remove static field accesses to library APIs when the results 54# are unused (E.g. tell it that it's okay to not trigger <clinit>). 55# Not using the return value generally occurs due to logging being stripped. 56-assumenosideeffects class android.**, java.** { 57 static <fields>; 58} 59 60# Causes R8 to more agressively optimize ServiceLoader.load() calls, by 61# assuming no exceptions will be thrown. 62-assumenosideeffects class java.util.ServiceLoader { 63 static *** load(...); 64} 65 66# Keep the names of exception types, to make it easier to understand stack 67# traces in contexts where it's not trivial to deobfuscate them - for example 68# when reported to app developers who are using WebView. 69-keepnames,allowaccessmodification class ** extends java.lang.Throwable {} 70 71# Should be removed once we use Android V SDK. b/336753747 72-keep class !cr_allowunused,androidx.privacysandbox.ads.adservices.internal.ContinuationOutcomeReceiver { 73 <methods>; 74} 75