-keepattributes *Annotation*

-keepclasseswithmembernames class * {
    native <methods>;
}

#-dontoptimize

#Okhttp
-dontwarn okhttp3.**
-dontwarn okio.**
-dontwarn javax.annotation.**
-dontwarn org.conscrypt.**
# A resource is loaded with a relative path so the package of this class must be preserved.
-keepnames class okhttp3.internal.publicsuffix.PublicSuffixDatabase

#Retofit
-keepattributes Signature, InnerClasses, EnclosingMethod

# Top-level functions that can only be used by Kotlin.
-dontwarn retrofit2.KotlinExtensions
-dontwarn retrofit2.KotlinExtensions$*

# Retain service method parameters when optimizing.
-keepclassmembers,allowshrinking,allowobfuscation interface * {
    @retrofit2.http.* <methods>;
}

# Ignore annotation used for build tooling.
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement

# Ignore JSR 305 annotations for embedding nullability information.
-dontwarn javax.annotation.**

# Guarded by a NoClassDefFoundError try/catch and only used when on the classpath.
-dontwarn kotlin.Unit

# Top-level functions that can only be used by Kotlin.
-dontwarn retrofit2.-KotlinExtensions

# With R8 full mode, it sees no subtypes of Retrofit interfaces since they are created with a Proxy
# and replaces all potential values with null. Explicitly keeping the interfaces prevents this.
-if interface * { @retrofit2.http.* <methods>; }
-keep,allowobfuscation interface <1>

#Okio
# Animal Sniffer compileOnly dependency to ensure APIs are compatible with older versions of Java.
-dontwarn org.codehaus.mojo.animal_sniffer.*

-keepclassmembers class * {
  @com.google.api.client.util.Key <fields>;
}

# Needed by google-http-client-android when linking against an older platform version
-dontwarn com.google.api.client.extensions.android.**

# Needed by google-api-client-android when linking against an older platform version
-dontwarn com.google.api.client.googleapis.extensions.android.**

# Needed by google-play-services when linking against an older platform version
-dontwarn com.google.android.gms.**

# com.google.client.util.IOUtils references java.nio.file.Files when on Java 7+
-dontnote java.nio.file.Files, java.nio.file.Path

# Suppress notes on LicensingServices
-dontnote **.ILicensingService

-dontwarn sun.misc.Unsafeclear

-dontwarn com.google.errorprone.**

-dontwarn java.lang.ClassValue

-keep class com.google.** {*;}

-keepclassmembers class com.microblink.** { *; }

# Keep Engage SDK scan results mapper (top-level Kotlin extension functions used cross-module via compileOnly)
-keep class com.microblink.ScanResultsMapper { *; }

# Prevent proguard from stripping interface information from TypeAdapter, TypeAdapterFactory,
# JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter)
-keep class * extends com.google.gson.TypeAdapter
-keep class * implements com.google.gson.TypeAdapterFactory
-keep class * implements com.google.gson.JsonSerializer
-keep class * implements com.google.gson.JsonDeserializer

# Prevent R8 from leaving Data object members always null
-keepclassmembers,allowobfuscation class * {
  @com.google.gson.annotations.SerializedName <fields>;
}

# Engage SDK is compileOnly - suppress missing class warnings for its transitive deps
-dontwarn org.koin.core.Koin
-dontwarn org.koin.core.KoinApplication
# Keep all classes except for RecognizerProxy which is used internally for Direct API access by Dev App
-keep class com.microblink.** {
    public <methods>;
    public <fields>;
}

-keepclasseswithmembernames class * {
    native <methods>;
}

# TripItemConfidence is constructed and populated from C++ via JNI (FindClass + GetMethodID
# "<init>" + GetFieldID); keep its name, no-arg constructor, and field names so the native
# layer can set them under R8 (incl. full mode). Covered by the broad com.microblink.** rule
# above, but kept explicit so the JNI contract survives any future narrowing of that rule.
-keep class com.microblink.internal.TripItemConfidence {
    <init>();
    <fields>;
}

# OcrResult is constructed and populated from C++ via JNI the same way (FindClass + GetMethodID
# "<init>" + GetFieldID on e.g. "instacartShopper", "isReturn"); its fields are public, so the
# broad com.microblink.** rule above covers it today, but the JNI contract is kept explicit for
# the same reason as TripItemConfidence.
-keep class com.microblink.OcrResult {
    <init>();
    <fields>;
}

# BarcodeDateTime is constructed/populated from C++ via JNI (parseDateFromBarcodeNative); keep its
# name, no-arg constructor, and String field names (date/time) so the native layer can set them.
-keep class com.microblink.internal.BarcodeDateTime {
    <init>();
    <fields>;
}

# Keep Activation SDK scan results mapper (top-level Kotlin extension functions used cross-module)
-keep class com.microblink.ScanResultsMapper { *; }

# Activation SDK is a compileOnly dependency. These classes may not be present
# at runtime if the host app does not include the Activation SDK. Suppress R8
# warnings for missing classes — all references are gated behind
# ActivationBridge.isActivationAvailable (Class.forName runtime check).
-dontwarn com.actualplatform.activation.**

# --- R8 full-mode safety for the Activation bridge ---
# Under R8 full mode, private members and constructors that are only reached
# via lazy-init / try/catch class-loading guards may be aggressively stripped
# or have their access modifiers rewritten. The ActivationBridge selects an
# implementation at runtime via Class.forName; explicitly retain the bridge,
# the Activation interface contract, both implementations, and their no-arg
# constructors so the dynamic dispatch survives full-mode shrinking.

-keep class com.microblink.internal.Activation { *; }

-keep class com.microblink.internal.ActivationBridge {
    public <methods>;
    public <fields>;
    private <methods>;
    private <fields>;
}

-keep class com.microblink.internal.ActivationBridge$NoOpActivation {
    <init>();
    <methods>;
    <fields>;
}

-keep class com.microblink.internal.ActivationsClient {
    <init>();
    <methods>;
    <fields>;
}

# Room's generated *_Impl classes under R8 full mode.
#
# This module puts androidx.work on your runtime classpath, and androidx.work brings androidx.room
# with it. Room's consumer rule named no members before 2.7.0:
#
#   -keep class * extends androidx.room.RoomDatabase
#
# R8 full mode - the AGP default for an app - does not implicitly keep a kept class's default
# constructor, so the generated androidx.work.impl.WorkDatabase_Impl survives by name but loses
# the <init>() Room instantiates it with, and WorkManager's initializer takes the app down on
# first launch with `NoSuchMethodException: androidx.work.impl.WorkDatabase_Impl.<init> []`.
#
# We resolve work-runtime 2.11.2, which brings Room 2.7.0 and the corrected rule, so this line is
# normally redundant. It is kept because pinning or substituting Room below 2.7.0 silently removes
# the rule Room ships, and the resulting break is invisible at build time and fatal at launch.
-keep class * extends androidx.room.RoomDatabase { void <init>(); }
