我看这个问题下 #70 说可以直接引用 KMP 库,但是为什么我引用 ktor 鸿蒙上编译不过?
`
Execution failed for task :shared:kspKotlinOhosArm64 .
Could not resolve all files for configuration :shared:ohosArm64CompileKlibraries .
Could not resolve io.ktor:ktor-server-netty:3.0.1.
Required by:
project :shared
> No matching variant of io.ktor:ktor-server-netty:3.0.1 was found. The consumer was configured to find a library for use during kotlin-api , preferably optimized for non-jvm, as well as attribute org.jetbrains.kotlin.native.target with value ohos_arm64 , attribute org.jetbrains.kotlin.platform.type with value native but:
– Variant jvmApiElements-published declares a library for use during compile-time, preferably optimized for standard JVMs:
– Incompatible because this component declares a component, as well as attribute org.jetbrains.kotlin.platform.type with value jvm and the consumer needed a component, as well as attribute org.jetbrains.kotlin.platform.type with value native
– Other compatible attribute:
– Doesn t say anything about org.jetbrains.kotlin.native.target (required ohos_arm64 )
– Variant jvmRuntimeElements-published declares a library for use during runtime, preferably optimized for standard JVMs:
– Incompatible because this component declares a component, as well as attribute org.jetbrains.kotlin.platform.type with value jvm and the consumer needed a component, as well as attribute org.jetbrains.kotlin.platform.type with value native
– Other compatible attribute:
– Doesn t say anything about org.jetbrains.kotlin.native.target (required ohos_arm64 )
– Variant jvmSourcesElements-published declares a component for use during runtime, preferably optimized for standard JVMs:
– Incompatible because this component declares documentation, as well as attribute org.jetbrains.kotlin.platform.type with value jvm and the consumer needed a library, as well as attribute org.jetbrains.kotlin.platform.type with value native
– Other compatible attribute:
– Doesn t say anything about org.jetbrains.kotlin.native.target (required ohos_arm64 )
– Variant metadataApiElements declares a library, preferably optimized for non-jvm:
– Incompatible because this component declares a component for use during kotlin-metadata , as well as attribute org.jetbrains.kotlin.platform.type with value common and the consumer needed a component for use during kotlin-api , as well as attribute org.jetbrains.kotlin.platform.type with value native
– Other compatible attribute:
– Doesn t say anything about org.jetbrains.kotlin.native.target (required ohos_arm64 )
– Variant metadataSourcesElements declares a component, preferably optimized for non-jvm:
– Incompatible because this component declares documentation for use during kotlin-runtime , as well as attribute org.jetbrains.kotlin.platform.type with value common and the consumer needed a library for use during kotlin-api , as well as attribute org.jetbrains.kotlin.platform.type with value native
– Other compatible attribute:
– Doesn t say anything about org.jetbrains.kotlin.native.target (required ohos_arm64 )
`
- 最新
- 最热
只看作者上述方案1就是适配鸿蒙的教程步骤
你使用的Kotlin 官方ktor未适配鸿蒙Kotlin Native,导致编译缺少OhosArm64 target。解决方案:
1、你参照KMP模块鸿蒙Kotlin Native适配,适配ktor到鸿蒙Kotlin Native
2、使用KuiklyBase开源的网络组件。这个组件在安卓 iOS上使用的是Ktor引擎,鸿蒙上使用的是libcurl引擎。
鸿蒙的话ktor最终还是要走curl,CIO不支持TLS,或者自己调用openssl实现TLS。不是有那么多网络操作存量代码的话,还是用腾讯的网络库吧,轻量一些。
@hidawei 我是需要将像 ktor 这种库源码下载下来,然后进行鸿蒙化改造是吗?有没有什么教程