ProGuard/R8 rules
Proguard (and its successor, R8) is a code-shrinking and obfuscation tool used by Android when building release apps. Without the necessary rules in place, Proguard might strip or rename classes that an SDK needs at runtime that causes app crashes.
The Didomi Android SDK includes ProGuard rules in its Android Archive (AAR) that is automatically applied to any Android application that integrates the SDK. Your organization does not need to copy or references these rules manually as they will take effect at build time. In this article, we provide an overview of the different ProGuard/R8 rules that are packaged with the Didomi Android SDK:
If your organization has a custom ProGuard configuration that conflicts (e.g. aggresive -keep or -obfuscate overrides) it my need to verify that these rules are not being overridden.
Core Didomi SDK classes rules
The following rules tell ProGuard to leave Didomi SDK classes untouched (they should not be removed nor renamed):
-keep class io.didomi.iabtcf.** { *; }
-keep class io.didomi.sdk.** { *; }Defensive/housekeeping rules
Preserves a specific enum used in TCF v2 decoding to work around a known bug in certain ProGuard versions
Suppresses a build warning about V8 (a JavaScript engine). The SDK no longer depends on V8 at runtime, but a reference may linger in the dependency tree.
Suppresses a warning about Kotlin's @Parcelize annotation plugin in certain build configurations.
Gson rules
The following rules are used to handle Gson:
Preserves generic type information Gson needs to read JSON into typed objects
Keeps @Expose and other Gson annotations
Suppresses a known harmless warning from Gson internals
Protects custom JSON adapters from being stripped
Protects custom JSON adapter factories from being stripped
Protects custom serializer/deserializer implementations
Prevents R8 from nullifying fields mapped from JSON using the @SerializedName annotation
Required for R8 v3.0+ to correctly handle generic type tokens
Firebase rules
The following rules apply to Android applications that use the Didomi Android SDK and Firebase Analytics with Google Consent Mode v2 enabled. Together, these rules protect Firebase Analytics classes that the Didomi Android SDK's Google Consent Mode v2 integration calls via reflection.
Reflection is a technique where code calls another class's methods by name at runtime rather than at compile time. This technique requires explicit ProGuard protection.
Last updated