简体   繁体   English

在 Kotlin Multiplatform 中使用 Java 库

[英]Using Java library with Kotlin Multiplatform

I'm looking towards expanding an Android application written in Kotlin to iOS, and I would like to use Kotlin Multiplatform for that.我希望将用 Kotlin 编写的 Android 应用程序扩展到 iOS,我想为此使用 Kotlin Multiplatform。 But since I have one big Java dependency, which is BouncyCastle, I'm not sure it's possible.但由于我有一个很大的 Java 依赖项,即 BouncyCastle,我不确定这是否可能。 Are there any alternatives for BouncyCastle for Kotlin or a way to use java library with multiplatform?有没有 BouncyCastle for Kotlin 的替代品或在多平台上使用 java 库的方法?

No, at least assuming you are using Kotlin Native on iOS, your not going to be able to use Bouncy Castle.不,至少假设您在 iOS 上使用 Kotlin Native,您将无法使用 Bouncy Castle。 If your doing something a bit weirder, like using Gluon to distribute a Java based app, then the dependency should just work.如果您做的事情有点奇怪,例如使用Gluon分发基于 Java 的应用程序,那么依赖项应该可以正常工作。 Instead you'll need to use to crypto facilities provided by iOS or another library such as CryptoSwift .相反,您需要使用 iOS 或其他库(例如CryptoSwift )提供的加密工具。

If your hoping to provide a common interface that can be used across multiple platforms, you can accomplish that with platform specific declarations , but the actual implementation is going to have to vary based on the platform.如果您希望提供可跨多个平台使用的通用接口,您可以使用特定平台的声明来实现,但实际实现将不得不因平台而异。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM