Vincent Barthelemy
09/11/2024, 2:28 PMktor-server-cio
but I run into dependency resolution error (I guess Ktor server CIO does not support android native as presented in the Supported platforms documentation).
I found this related question with an answer mentioning a "partial support" but I suspect that "native/android" was referring to "native targets and/or android (jvm) target", not "android native target".
Does someone managed to make ktor-server
work from android native binary and/or have some pointers I could look at? 🙏Bruce Hamilton
09/11/2024, 2:39 PMVincent Barthelemy
09/11/2024, 4:06 PMVincent Barthelemy
09/11/2024, 9:19 PMdiff --git a/buildSrc/src/main/kotlin/Publication.kt b/buildSrc/src/main/kotlin/Publication.kt
index 1b62c68b0..6d02ae1f9 100644
--- a/buildSrc/src/main/kotlin/Publication.kt
+++ b/buildSrc/src/main/kotlin/Publication.kt
@@ -47,6 +47,15 @@ fun isAvailableForPublication(publication: Publication): Boolean {
"macosArm64"
)
+ val androidPublication = setOf(
+ "androidNativeArm32",
+ "androidNativeArm64",
+ "androidNativeX64",
+ "androidNativeX86"
+ )
+
+ result = result || name in androidPublication
+
result = result || (HOST_NAME == "macos" && name in macPublications)
return result
• Running ./gradlew publishToMavenLocal
to publish artifacts locally make it possible to depends on io.ktor:ktor-server-cio
and io.ktor:ktor-server-server
from android native source sets.
• Pushing the final binary on an Android Emulator and starting the server worked perfectly (at least for a simple "Hello World" exemple)
• Forwarding ports with adb made it even possible to reach the web server running on the android emulator from a browser running on the host machine ! 🎉
Thanks again @Bruce Hamilton for pointing me in the right direction! Made my day :)