简体   繁体   English

Kotlin 多平台错误:指令与文件位置不匹配

[英]Kotlin Multiplatform error: directive doesn't match file location

I'm trying to share code between Android and iOS with Kotlin Multiplatform.我正在尝试使用 Kotlin Multiplatform 在 Android 和 iOS 之间共享代码。 The sharing part works perfectly but I have some issues to import in a common file the androidApp package.共享部分工作正常,但我有一些问题要在通用文件中导入 androidApp 包。 I would like to use the res folder located in androidApp in the shared class.我想在共享类中使用位于 androidApp 中的 res 文件夹。 This is my tree directory 1 :这是我的树目录1

DirectoryTree目录树

Thanks!谢谢!

Usually you don't have to import specific platform package to the shared part.通常您不必将特定平台包导入共享部分。

The direction is quite the opposite.方向正好相反。

Use the shared part in the native ones.使用本机中的共享部分。

If you need to share resources in an Android manner I suggest you to have a look here:如果您需要以 Android 方式共享资源,我建议您查看这里:

https://github.com/icerockdev/moko-resources https://github.com/icerockdev/moko-resources

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

相关问题 使用 Kotlin Multiplatform Mobile (KMM) 的多平台应用程序中的数据绑定错误 - DataBinding error in multiplatform app using Kotlin Multiplatform Mobile (KMM) Kotlin Multiplatform Android导入无法解决 - Kotlin Multiplatform Android Imports won't resolve 为 Kotlin 多平台项目运行单元测试时出错 - Error Running Unit Tests for Kotlin Multiplatform Project 无法在 Kotlin 多平台项目中调试 iOS 应用程序 - Can't debug iOS application in Kotlin multiplatform project 如何修复 Kotlin Multiplatform Mobile gradle 红色错误 - how to fix Kotlin Multiplatform Mobile gradle red error 从项目目录读取本地文件 | Kotlin 多平台手机 | 知识管理系统 - Read local file from project directory | Kotlin Multiplatform Mobile | KMM 在 Kotlin 多平台项目中使用 Ktor HttpClient 将文件作为二进制文件 - Put File as Binary with Ktor HttpClient in Kotlin Multiplatform Project KMM Kotlin 多平台移动错误:无法检测已安装 Xcode 的版本 - KMM Kotlin Multiplatform Mobile Error: Could not detect version of installed Xcode 当我传递 MutableList 的 var 时,为什么 Android Studio 不启动错误<file>列出<file>在 Kotlin 中?</file></file> - Why doesn't the Android Studio launch an error when I pass a var of MutableList<File> to List<File> in Kotlin? Kotlin 多平台模块库 - Kotlin Multiplatform Module Library
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM