Hi! I'm using ktor on Android to server a simple ...
# ktor
b
Hi! I'm using ktor on Android to server a simple webpage. It works... except in release mode (with proguard enabled) only part of the file is served, and then I see an exception in the logs. After googling a bit, I've tried to add some proguard rules, but it didn't change anything. Also the stacktrace is very cryptic (see thread below).
🤓 1
The stacktrace:
Copy code
E/ktor.application: 200 OK: GET - /
    java.lang.NullPointerException: throw with null exception
        at io.ktor.routing.Routing$executeResult$1.invokeSuspend(Routing.kt)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:32)
        at io.ktor.util.pipeline.SuspendFunctionGun.resumeRootWith(PipelineContext.kt:183)
        at io.ktor.util.pipeline.SuspendFunctionGun.access$resumeRootWith(PipelineContext.kt:63)
        at io.ktor.util.pipeline.SuspendFunctionGun$continuation$1.resumeWith(PipelineContext.kt:88)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:45)
        at io.ktor.util.pipeline.SuspendFunctionGun.resumeRootWith(PipelineContext.kt:183)
        at io.ktor.util.pipeline.SuspendFunctionGun.access$resumeRootWith(PipelineContext.kt:63)
        at io.ktor.util.pipeline.SuspendFunctionGun$continuation$1.resumeWith(PipelineContext.kt:88)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:45)
        at io.ktor.util.pipeline.SuspendFunctionGun.resumeRootWith(PipelineContext.kt:183)
        at io.ktor.util.pipeline.SuspendFunctionGun.access$resumeRootWith(PipelineContext.kt:63)
        at io.ktor.util.pipeline.SuspendFunctionGun$continuation$1.resumeWith(PipelineContext.kt:88)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:45)
        at kotlinx.coroutines.DispatchedTask.run(Dispatched.kt:234)
        at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163)
        at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:404)
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:463)
        at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:884)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.lang.Thread.run(Thread.java:776)
The proguard rules I added:
Copy code
-keep class io.ktor.server.netty.DevelopmentEngine {*;}
-keep class kotlin.reflect.jvm.internal.** {*;}
-keep class kotlin.text.RegexOption {*;}
( I ended up disabling proguard altogether 😞 )
l
I had similar issue and the following proguard rule solved my problem.
Copy code
-keep class io.ktor.** { *; }
Did you find a better way?
b
to be honest I stopped using Ktor altogether in the end. It's simply not meant to be compatible with Android
l
I see. It seems like it will take more time to be mature. Thanks for the reply.
👍 1