Jiri Bruchanov
12/14/2019, 11:51 AM1.3.0-beta-2
on android 4.4 and 5 and probably any other with jvm1.6, because of
java.lang.NoSuchMethodError: No virtual method toPath()Ljava/nio/file/Path; in class Ljava/io/File; or its super classes (declaration of '<http://java.io|java.io>.File' appears in /system/framework/core-libart.jar)
also with 1.3.0-beta-1
I'm getting following
ktor-server-netty
java.lang.NoClassDefFoundError: io.ktor.application.ApplicationEvents$subscribe$1
at io.ktor.application.ApplicationEvents.subscribe(ApplicationEvents.kt:22)
at io.ktor.server.engine.BaseApplicationEngine.<init>(BaseApplicationEngine.kt:31)
at io.ktor.server.engine.BaseApplicationEngine.<init>(BaseApplicationEngine.kt:21)
at io.ktor.server.netty.NettyApplicationEngine.<init>(NettyApplicationEngine.kt:27)
at io.ktor.server.netty.Netty.create(Embedded.kt:14)
at io.ktor.server.netty.Netty.create(Embedded.kt:12)
at io.ktor.server.engine.EmbeddedServerKt.embeddedServer(EmbeddedServer.kt:79)
at io.ktor.server.engine.EmbeddedServerKt.embeddedServer(EmbeddedServer.kt:67)
at io.ktor.server.engine.EmbeddedServerKt.embeddedServer(EmbeddedServer.kt:36)
at io.ktor.server.engine.EmbeddedServerKt.embeddedServer$default(EmbeddedServer.kt:34)
at com.scurab.android.anuitor.service.KtorServer.start(KtorServer.kt:50)
....
ktor-server-jetty
MethodHandle.invoke and MethodHandle.invokeExact are only supported starting with Android O (--min-api 26)
Path
in routing it works fine, which was just
static { files(File(root)) }
in my case...cy
12/14/2019, 12:07 PMJiri Bruchanov
12/14/2019, 12:08 PMcy
12/14/2019, 12:09 PMJiri Bruchanov
12/14/2019, 12:14 PMstatic
in my case ?
I wrote this
fun Route.supportFiles(folder: File) {
fun File?.combine(file: File) = when {
this == null -> file
else -> resolve(file)
}
val pathParameterName = "static-content-path-parameter"
val dir = staticRootFolder.combine(folder)
get("{$pathParameterName...}") {
val relativePath = call.parameters.getAll(pathParameterName)?.joinToString(File.separator) ?: return@get
val file = dir.combineSafe(relativePath)
if (file.isFile) {
call.respond(file.readBytes())
}
}
}
and then
static { supportFiles(File(root)) }
which works fine, but it's just quick copy&paste of the ktor
code with explicit file reading