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 flags that we'd like all Chromium .apks to use. 6 7# Keep line number information, useful for stack traces. 8-keepattributes SourceFile,LineNumberTable 9 10# Enable protobuf-related optimizations. 11-shrinkunusedprotofields 12 13# Allowing Proguard to change modifiers. 14-allowaccessmodification 15 16# Keep all CREATOR fields within Parcelable that are kept. 17-keepclassmembers class !cr_allowunused,** implements android.os.Parcelable { 18 public static *** CREATOR; 19} 20 21# Don't obfuscate Parcelables as they might be marshalled outside Chrome. 22# If we annotated all Parcelables that get put into Bundles other than 23# for saveInstanceState (e.g. PendingIntents), then we could actually keep the 24# names of just those ones. For now, we'll just keep them all. 25-keepnames class !cr_allowunused,** implements android.os.Parcelable {} 26 27# Keep all default constructors for used Fragments. Required since they are 28# called reflectively when fragments are reinflated after the app is killed. 29-keepclassmembers class !cr_allowunused,** extends android.app.Fragment { 30 public <init>(); 31} 32-keepclassmembers class !cr_allowunused,** extends androidx.fragment.app.Fragment { 33 public <init>(); 34} 35 36# Keep all enum values and valueOf methods. See 37# http://proguard.sourceforge.net/index.html#manual/examples.html 38# for the reason for this. Also, see http://crbug.com/248037. 39-keepclassmembers enum !cr_allowunused,** { 40 public static **[] values(); 41} 42 43# This is to workaround crbug.com/1204690 - an old GMS app version crashes when 44# ObjectWrapper contains > 1 fields, and this prevents R8 from inserting a 45# synthetic field. 46-keep,allowaccessmodification class !cr_allowunused,com.google.android.gms.dynamic.ObjectWrapper { 47 <fields>; 48} 49 50# Remove calls to String.format() where the result goes unused. This can mask 51# exceptions if the parameters to String.format() are invalid, but such cases 52# are generally programming bugs anyways. 53# Not using the return value generally occurs due to logging being stripped. 54-assumenosideeffects class java.lang.String { 55 static java.lang.String format(...); 56} 57 58# Allows R8 to remove static field accesses to library APIs when the results 59# are unused (E.g. tell it that it's okay to not trigger <clinit>). 60# Not using the return value generally occurs due to logging being stripped. 61-assumenosideeffects class android.**, java.** { 62 static <fields>; 63} 64 65# Keep the names of exception types, to make it easier to understand stack 66# traces in contexts where it's not trivial to deobfuscate them - for example 67# when reported to app developers who are using WebView. 68-keepnames class ** extends java.lang.Throwable {} 69