I found that this channel exists; so perhaps you g...
# supabase-kt
n
I found that this channel exists; so perhaps you guys might have some input on my issues. I am unable to make a release of my app for Desktop. Android works fine, as well as web/wasm. Original post: https://kotlinlang.slack.com/archives/C01D6HTPATV/p1741858500964859 Basically it's one of these; • Proguard complains and I am not able to make a release build.
Copy code
io.ktor.network.sockets. SocketBase$ attachFor$ 1:  can't find enclosing method 'io.ktor.utils.io.ChannelJob attachFor(java.lang. String, io. ktor. utils. io. ByteChannel, kotlinx. atomicfu. AtomicRef, kotlin. jvm. functions. Function0) '  in program class io.ktor.network.sockets. SocketBase
• I am able to make the releaseDistribution and it crashes on startup blaiming
Copy code
io.ktor.client.HttpClienEngineContainer:  Provider io.ktor.client.engine. cio. CIOEngineContainer not found
j
Let me see if I can reproduce this
Btw got your email, couldn't take a look at it until now
1
n
Awesome, cheers!
j
Okay, so I was able to fix these errors with:
Copy code
-dontwarn io.ktor.network.sockets.SocketBase
-keep class io.ktor.client.engine.cio.** { *; }
-keep class io.ktor.client.HttpClientEngineContainer { *; }
But then a Ktor Serialization issue appeared, which I fixed with:
Copy code
-keep class io.ktor.serialization.kotlinx.KotlinxSerializationExtensionProvider { *; }
-keep class io.ktor.serialization.kotlinx.json.KotlinxSerializationJsonExtensionProvider { *; }
🥂 1
n
Thank you so much for looking into this for me! 😄 The rules don't fix it for us, but that might be because of our multi-module setup. We'll look into it
@Jan if it would be feasible to ask; how would it work if you moved the supabase postgrest into a "lower module"? so
:app -> :repo
j
Not sure if I understand, do you mean the Postgrest module to its own repo?
The rules don't fix it for us, but that might be because of our multi-module setup. We'll look into it
Also, did you check if the proguard file actually gets used? Or where are you loading it
n
We are using the supabase lib, and provided ktor dependencies in
:sdk:client_platform
; we might combine/flatten some modules and simplify but that's what we have right now.
I am not 100% sure what I did to make it work; but I am now able to make a release distribution for the current desktop OS 👍 But the rules comes with a follow up issue: if I remove
-dontoptimize
from the ProGuard files then the Ktor optimisation gets weird because it struggles with incomplete preservations or that is what the AS Gemini tells me. I get this error:
Unexpected error while writing class [data/source/EarlyBackers] (Overflow of unsigned short value [131070])
Here's my
:proguardReleaseJars
output at the time of the error:
Copy code
Note: the configuration keeps the entry point 'io.ktor.client.engine.cio.UtilsKt$writeRequest$2 { UtilsKt$writeRequest$2(io.ktor.client.request.HttpRequestData,io.ktor.utils.io.ByteWriteChannel,boolean,boolean,kotlin.coroutines.CoroutineContext,kotlin.coroutines.Continuation); }', but not the descriptor class 'io.ktor.client.request.HttpRequestData'
Note: the configuration keeps the entry point 'io.ktor.client.engine.cio.UtilsKt$writeRequest$2 { UtilsKt$writeRequest$2(io.ktor.client.request.HttpRequestData,io.ktor.utils.io.ByteWriteChannel,boolean,boolean,kotlin.coroutines.CoroutineContext,kotlin.coroutines.Continuation); }', but not the descriptor class 'io.ktor.utils.io.ByteWriteChannel'
Unexpected error
java.lang.RuntimeException: Unexpected error while writing class [data/source/EarlyBackers] (Overflow of unsigned short value [131070])
	at proguard.io.ClassDataEntryWriter.createOutputStream(ClassDataEntryWriter.java:104) ~[proguard-core-9.1.0.jar:7.4.0]
There are a bunch of similar "Note: keep entry point + but not descriptor" before the error.
Latest news is that I have flattened the modules and got it working; if I apply
-dontoptimise
flag If I remove it I get a bunch of "Note"s/warnings regarding keeps and descriptors ex: Note: the configuration keeps the entry point 'io.ktor.util.AttributeKey { io.ktor.util.AttributeKey copy$default(io.ktor.util.AttributeKey,java.lang.String,io.ktor.util.reflect.TypeInfo,int,java.lang.Object); }', but not the descriptor class 'io.ktor.util.reflect.TypeInfo' And the error: Caused by: java.lang.IllegalArgumentException: Overflow of unsigned short value [131070]
j
I must say I'm no ProGuard expert and ProGuard on Desktop seems to always complicate things. Maybe anyone here has an idea, but I'd say this is more of a Ktor / ProGuard issue
n
Yes, it's gone beyond the Supabase lib and I'm super grateful for your input ☺️