大佬教程收集整理的这篇文章主要介绍了Kotlin KMM 'commonMain' 依赖项:运行正常,AndroidStudio 显示错误,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我确实按照此处所述设置了 KMM 项目:https://kotlinlang.org/docs/mobile/getTing-started.html
我想在 commonMain
模块中放置一些共享类。这些类需要一些依赖项。所以我添加了这里描述的依赖项:https://kotlinlang.org/docs/mobile/add-dependencies.html#dependency-on-a-library-used-in-specific-source-sets
shared/build.gradle.kts
(缩短)
....
kotlin {
androID()
ios {
binarIEs {
framework {
basename = "shared"
}
}
}
sourceSets {
val commonMain by getTing {
dependencIEs {
implementation("org.jetbrains.kotlin:kotlin-reflect:1.4.31")
}
}
...
val androIDMain by getTing {
dependencIEs {
}
}
....
val iosmain by getTing
val iosTest by getTing
}
}
....
所以我创建了这个 InjectManager
Helper 类,它使用了 kotlin-reflect
库。
问题:
AndroIDstudio (4.1.3) 在类放在 commonMain
中时无法找到依赖项,只有放在 androIDMain
中时才能找到。当我运行项目时 - 没有错误 - 一切正常。这正是 AndroID studio 的看法。 InjectManager
和 InjectManager2
具有相同的代码。为了能够使用自动完成等,我目前的工作流程是这样的
androIDMain
commonMain
。InjectManager2
仅用于在屏幕截图中显示。
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)
以上是大佬教程为你收集整理的Kotlin KMM 'commonMain' 依赖项:运行正常,AndroidStudio 显示错误全部内容,希望文章能够帮你解决Kotlin KMM 'commonMain' 依赖项:运行正常,AndroidStudio 显示错误所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。