I am using the fabulous <Supabase-kt> lib in my KM...
# compose-desktop
n
I am using the fabulous Supabase-kt lib in my KMP app. It targets Android, Desktop, iOS and Web. The library works fine in terms of functionality - but I am unable to make a release build; or rather I get an exception as soon as I start up the app. The library requires me to provide dependencies for Ktor (which I do with core and cio, darwin, js ). This is what I run to make the release distribution
app_cmp:composeApp: packageReleaseDistributionForCurrentOS
I get this exception:
io.ktor.client.HttpClienEngineContainer:  Provider io.ktor.client.engine. cio. CIOEngineContainer not found.
My Gradle/Module setup
Copy code
// This hasn't changed since an initial setup; so things might be over-engineered in places.
root
| - app_cmp
  | - composeApp (src)
    | - androidMain
    | - commonMain
    | - desktopMain
    | - iosMain
    | - wasmJsMain
  | - studio (shared design module)
| - core (shared util/models module)
| - sdk
  | - clientDomain (common)
  | - dataModels (common)
  | - clientData (all targets)
  | - clientPlatform (all targets)
We're using Supabase bom + auth.ui :composeApp. And bom+auth/postgres/realtime in :clientPlatform. Have anyone experience with the
Supabase-kt
lib for a release build? And I suspect this has to do with Proguard etc. If anyone has an example of a KMP/CMP project targeting all platforms that uses proguard (with different module) that would be a great resource to have a look at. ThanK you!
c
i asked a question about proguard here sorta recently. maybe some of the comments in there help. https://kotlinlang.slack.com/archives/C01D6HTPATV/p1740603348777239
n
I saw that post because before getting to this issue I had a similar issue with @Serialization. I have a couple of resources that I tried to use; this article, and your thread. I tried looking at the app from Romain Guy - but in the end I'm just not sure where my problem lies and I can't find the actual issues. I've added this proguard file; but I really have no idea what I'm doing 🤷
Copy code
-dontoptimize

# Keep `Companion` object fields of serializable classes.
# This avoids serializer lookup through `getDeclaredClasses` as done for named companion objects.
-if @kotlinx.serialization.Serializable class **
-keepclassmembers class <1> {
    static <1>$Companion Companion;
}

# Keep `serializer()` on companion objects (both default and named) of serializable classes.
-if @kotlinx.serialization.Serializable class ** {
    static **$* *;
}
-keepclassmembers class <2>$<3> {
    kotlinx.serialization.KSerializer serializer(...);
}

# Keep `INSTANCE.serializer()` of serializable objects.
-if @kotlinx.serialization.Serializable class ** {
    public static ** INSTANCE;
}
-keepclassmembers class <1> {
    public static <1> INSTANCE;
    kotlinx.serialization.KSerializer serializer(...);
}

# @Serializable and @Polymorphic are used at runtime for polymorphic serialization.
-keepattributes RuntimeVisibleAnnotations,AnnotationDefault

# Don't print notes about potential mistakes or omissions in the configuration for kotlinx-serialization classes
# See also <https://github.com/Kotlin/kotlinx.serialization/issues/1900>
-dontnote kotlinx.serialization.**

# Serialization core uses `java.lang.ClassValue` for caching inside these specified classes.
# If there is no `java.lang.ClassValue` (for example, in Android), then R8/ProGuard will print a warning.
# However, since in this case they will not be used, we can disable these warnings
-dontwarn kotlinx.serialization.internal.ClassValueReferences

# disable optimisation for descriptor field because in some versions of ProGuard, optimization generates incorrect bytecode that causes a verification error
# see <https://github.com/Kotlin/kotlinx.serialization/issues/2719>
-keepclassmembers public class **$$serializer {
    private ** descriptor;
}
I also don't know how much the different modules impact anything; and if I need consume files - or if I should just have one Proguard file. I've looked into more tickets and articles from the first article and I find some things here and there that might help, but in the end I just can't add enough to the proguard file to solve anything. Here's "a solution" for ktor / Serialization; but I am not the one using the Serialisation, that's in the Supabase lib https://youtrack.jetbrains.com/issue/KTOR-6703/Receiving-a-deserialized-body-fails-on-JVM-when-using-Proguard
c
yeah. im not much help because even when I copied Romains config, after creating a build (via conveyor) it seemed like the app wasn't ever being proguarded (the app size was the same). its on my list of stuff to look into. dexguard (the company that makes proguard) has a proguard playground https://playground.proguard.com/ i went on a kick to learn proguard a while back for android dev, but then android added the ability to ship proguard rules within a library and so for android proguard is essentially flipping a switch and 99% of the time it just works.