Skip to main content

Proguard/R8 rules

Consumer Rules (SDK 1.4.0 and later, including 2.0.x)

The Kotzilla SDK includes consumer ProGuard rules that are automatically applied to your app. These rules preserve essential SDK classes and handle kotlinx.serialization requirements.

No manual ProGuard configuration is needed for most projects.

The SDK automatically includes consumer rules for:

  • Core SDK classes (io.kotzilla.sdk.**, io.kotzilla.data.json.**)
  • kotlinx.serialization support

Multiple Keys with Flavors (SDK 2.1.3 to 2.3.6)​

If your kotzilla.json contains several keys sharing the same applicationPackageName, the SDK confirms the key for the running variant at app startup by reading FLAVOR and BUILD_TYPE from your app's BuildConfig.

In minified release builds, R8 removes the BuildConfig class because no code references it. The SDK then can't identify the flavor and falls back to the key marked isDefault: true, so your release build reports to the wrong app.

Add this rule to your app module's proguard-rules.pro:

-keep class **.BuildConfig {
public static final java.lang.String FLAVOR;
public static final java.lang.String BUILD_TYPE;
}

Also make sure BuildConfig generation is enabled in your app module (it's disabled by default since AGP 8):

android {
buildFeatures {
buildConfig = true
}
}
How to check

With debug logs enabled, the SDK logs the key it selected at startup. The wrong key looks like this:

[KotzillaSDK] Multi-key: using key ... isDefault=true, reason='default', ... flavorCandidates='<none>'

With the rule applied, you should see reason='package-and-flavor' and your variant's flavor in flavorCandidates.

Manual Configuration (Advanced)​

If you need to customize ProGuard rules or your build doesn't automatically apply consumer rules, add the following to your ProGuard file:

-keep class io.kotzilla.data.json.** { *; }
-keep class io.kotzilla.sdk.** { *; }

Additionally, ensure to keep classes related to Kotlin serialization and multiplatform settings:

-keepclassmembers class kotlinx.** { volatile <fields>; }
-keep class com.russhwolf.settings.** { *; }

R8 Compatibility​

R8 Support

All ProGuard rules are fully compatible with R8 (the modern code shrinker used by Android Gradle Plugin 8.0+).

R8 automatically applies the SDK's consumer rules during the build process, ensuring correct behavior in release builds without additional configuration.

Native HTTP Client (SDK 1.4.0 and later)​

No External HTTP Dependencies

Starting with SDK 1.4.0 (and continuing in 2.0.x), the SDK uses platform-native HTTP clients instead of external libraries like Ktor or OkHttp.

You do not need any Ktor or OkHttp ProGuard rules for the Kotzilla SDK.

If you previously used rules like -keep class io.ktor.** { *; } for the SDK, these can be safely removed.