# ============================================================
# Consumer ProGuard / R8 rules for Adster GAM/AdMob Custom Adapter
# These rules are AUTOMATICALLY applied to any app that includes this AAR.
# The consuming app does NOT need to add any rules manually.
# ============================================================

# ===========================================
# 1. ADAPTER CLASSES (loaded by GMA SDK via reflection)
# ===========================================
# Google Mobile Ads SDK instantiates the adapter by its fully qualified class
# name configured in AdMob/GAM dashboard. R8 cannot trace this reflection,
# so we must explicitly keep the class, its constructors, and all members.
-keep public class com.adster.ads.mediation.adapter.AdSterMediationAdapter { *; }

# Keep ALL classes in the adapter package including inner classes.
# Inner classes are used for ad listeners/callbacks that get invoked
# by the Adster SDK via interface dispatch.
-keep class com.adster.ads.mediation.adapter.** { *; }

# Keep Kotlin top-level extension functions (compiled as UtilKt)
-keep class com.adster.ads.mediation.UtilKt { *; }

# ===========================================
# 2. ADSTER SDK PUBLIC API
# ===========================================
# The adapter calls into these classes. Even though references exist,
# R8 aggressive mode or whole-program optimization can strip members
# that appear unused from the app's perspective.
-keep class com.adster.sdk.mediation.** { *; }

# ===========================================
# 3. @KEEP ANNOTATION SUPPORT
# ===========================================
-keep @androidx.annotation.Keep class * { *; }
-keepclassmembers class * {
    @androidx.annotation.Keep *;
}

# ===========================================
# 4. KOTLIN METADATA & LANGUAGE FEATURES
# ===========================================
-keepattributes *Annotation*, Signature, InnerClasses, EnclosingMethod
-keepattributes RuntimeVisibleAnnotations, RuntimeVisibleParameterAnnotations
-keep class kotlin.Metadata { *; }
-dontwarn kotlin.**
-dontwarn kotlinx.coroutines.**

# ===========================================
# 5. GSON SERIALIZATION (used by Adster SDK for API responses)
# ===========================================
-keepclassmembers,allowobfuscation class * {
    @com.google.gson.annotations.SerializedName <fields>;
}
-keep class * implements com.google.gson.TypeAdapterFactory
-keep class * implements com.google.gson.JsonSerializer
-keep class * implements com.google.gson.JsonDeserializer
-keep class com.google.gson.** { *; }
-dontwarn com.google.gson.**

# ===========================================
# 6. RETROFIT & OKHTTP (used by Adster SDK for networking)
# ===========================================
-keepclasseswithmembers interface * {
    @retrofit2.http.* <methods>;
}
-keep class retrofit2.** { *; }
-dontwarn retrofit2.**
-keep class okhttp3.** { *; }
-dontwarn okhttp3.**
-dontwarn okio.**

# ===========================================
# 7. GOOGLE MOBILE ADS SDK
# ===========================================
-keep class com.google.android.gms.ads.** { *; }
-keep class com.google.ads.** { *; }
-dontwarn com.google.android.gms.ads.**

# ===========================================
# 8. MISC SUPPRESSIONS
# ===========================================
-dontwarn java.lang.invoke.StringConcatFactory
