Ktor: Proguard on Android issues

Created on 5 Apr 2018  路  8Comments  路  Source: ktorio/ktor

Hi, i'm using ktor for simple rest server on Android app. Everything works fine, but if i run proguard, then hell is unleashed and i have over 680 issues with progurad.
100% problems is resolved by:

-dontwarn io.netty.**
-dontwarn io.ktor.**
-dontwarn com.typesafe.**

But server is not responding after start so i'm assuming, that proguard rules should be different :)

Most helpful comment

@soywiz you just close the minify, that does not really solve the problem, ^^,
Could you guide us how to config the proguard-rules.pro for ktor-android?

All 8 comments

@soywiz in android we use proguard-rules.pro file
i've tried to move this file as rules:

-keep class io.ktor.server.netty.DevelopmentEngine {*;}
-keep class kotlin.reflect.jvm.internal.** {*;}
-keep class io.ktor.samples.hello.HelloApplicationKt {*;}
-keep class kotlin.text.RegexOption {*;}

And i've over ~680 errors still, like

...
Warning: io.netty.handler.ssl.ConscryptAlpnSslEngine$BufferAdapter: can't find superclass or interface org.conscrypt.AllocatedBuffer
Warning: io.netty.handler.ssl.ConscryptAlpnSslEngine$BufferAllocatorAdapter: can't find superclass or interface org.conscrypt.BufferAllocator
...
Warning: com.typesafe.config.impl.ConfigBeanImpl: can't find referenced class java.beans.PropertyDescriptor
Warning: com.typesafe.config.impl.ConfigBeanImpl: can't find referenced class java.beans.BeanInfo
...
Warning: io.ktor.util.SSLKt: can't find referenced class sun.security.x509.X509CertInfo
Warning: io.ktor.util.SSLKt: can't find referenced class sun.security.x509.CertificateSerialNumber
...

Warning: io.netty.util.internal.logging.Log4J2LoggerFactory: can't find referenced class org.apache.logging.log4j.LogManager
Warning: io.netty.util.internal.logging.Log4J2LoggerFactory: can't find referenced class org.apache.logging.log4j.LogManager

@soywiz you just close the minify, that does not really solve the problem, ^^,
Could you guide us how to config the proguard-rules.pro for ktor-android?

This worked for me. Running release apk works too.

# Ktor
-keep class io.ktor.** { *; }
-keep class kotlinx.coroutines.** { *; }
-dontwarn kotlinx.atomicfu.**
-dontwarn io.netty.**
-dontwarn com.typesafe.**
-dontwarn org.slf4j.**

This issue has been automatically marked as stale because it has not had recent activity.

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.

Fixed in the origin issue

Was this page helpful?
0 / 5 - 0 ratings

Related issues

KennethanCeyer picture KennethanCeyer  路  4Comments

evgfilim1 picture evgfilim1  路  4Comments

SimonSchubert picture SimonSchubert  路  4Comments

baruchn picture baruchn  路  3Comments

diaodou picture diaodou  路  3Comments