xref: /aosp_15_r20/external/gson/examples/android-proguard-example/README.md (revision a8de600362638ea28fd6cb3225451dc706d269bb)
1*a8de6003SAndroid Build Coastguard Worker# android-proguard-example
2*a8de6003SAndroid Build Coastguard Worker
3*a8de6003SAndroid Build Coastguard WorkerExample Android project showing how to properly configure [ProGuard](https://www.guardsquare.com/proguard).
4*a8de6003SAndroid Build Coastguard WorkerProGuard is a tool for 'shrinking' and obfuscating compiled classes. It can rename methods and fields,
5*a8de6003SAndroid Build Coastguard Workeror remove them if they appear to be unused. This can cause issues for Gson which uses Java reflection to
6*a8de6003SAndroid Build Coastguard Workeraccess the fields of a class. It is necessary to configure ProGuard to make sure that Gson works correctly.
7*a8de6003SAndroid Build Coastguard Worker
8*a8de6003SAndroid Build Coastguard WorkerAlso have a look at the [ProGuard manual](https://www.guardsquare.com/manual/configuration/usage#keepoverview)
9*a8de6003SAndroid Build Coastguard Workerfor more details on how ProGuard can be configured.
10*a8de6003SAndroid Build Coastguard Worker
11*a8de6003SAndroid Build Coastguard WorkerThe R8 code shrinker uses the same rule format as ProGuard, but there are differences between these two
12*a8de6003SAndroid Build Coastguard Workertools. Have a look at R8's Compatibility FAQ, and especially at the [Gson section](https://r8.googlesource.com/r8/+/refs/heads/main/compatibility-faq.md#gson).
13