Kotlin Multipplatform - 在 Android Studio 文件夹树中看不到 Greeting.kt

发布于 2025-01-17 05:25:03 字数 610 浏览 0 评论 0原文

我刚刚开始学习 KMM(我现在是 Android java 人员),并经历了自动放入新应用程序中的 Hello World 的默认问候语版本。我的环境似乎正常工作,因为我能够在 Android 和 iOS 模拟器上运行默认应用程序。

但是我在项目树中看不到文件 Greeting.kt。我当然可以搜索它并从“查找”中打开它,但是当我向下钻取树共享/commonMain/kotlin/com.myapp...时,它只显示平台。

我有一个屏幕盖,显示顶部打开的 Greeting.kt 的路径,但在树中不可见:(

屏幕盖)

不幸的是,我无法发布图像(没有足够的声誉),但是当我打开文件时通过在项目中查找,Greeting.kt 在屏幕顶部显示路径(我的应用程序 > 共享 > src > commonMain > kotlin > com > example > myapplication > Greeting),但是当我手动深入 Android Studio 左侧的项目树时,Greeting.kt 没有显示。

我还可以在 Mac Finder 中找到该文件。我猜 Android Studio 中的首选项不正确?

关于可能出什么问题有什么想法吗?

提前致谢

I am just starting to learn KMM (I'm an Android java guy right now) and going through the default Greeting version of Hello World that is automatically put into a new application. My environment seems to be working as I was able to run the default app on both Android and iOS emulators.

However I can't see the file Greeting.kt in the Project tree. I can certainly search for it and open it from Find, but when I drill down the tree shared/commonMain/kotlin/com.myapp... it only shows Platform.

I have a screen cap that shows the path of the open Greeting.kt at the top, but not visible in the tree:

(screen cap)

Unfortunately I can't post an image (not enough reputation), but when I open the file Greeting.kt by doing a Find In Project, it shows the path at the top of the screen (My Application > shared > src > commonMain > kotlin > com > example > myapplication > Greeting), but when I manually drill down the Project tree on the left side of Android Studio Greeting.kt does not show up.

I can also find the file in the Mac Finder. My guess a preference in Android Studio is incorrect?

Any ideas on what might be wrong?

Thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

子栖 2025-01-24 05:25:03

原来是官方的bug。解决方案是升级到 Android Studio (Chipmunk) 的 Beta 版本

我向 Google 提交了一份错误报告,他们对此进行了调查:

根本原因是[Android Studio]Chipmunk之前的源码集
设置不正确,所以即使它在你的
屏幕截图(来自#2),如果您在该源下打开 Platform.kt
设置,你会发现它实际上是
共享/src/androidMain/kotlin/com/example/myapplication/Platform.kt。
[Android Studio] Chipmunk 修复了此问题。

Turns out it was an official bug. Solution is to upgrade to Beta version of Android Studio (Chipmunk)

I submitted a bug report to Google and they looked into it:

The root cause is that before [Android Studio]Chipmunk the source set
setup was incorrect, so even though it says commonMain in your
screenshot (from #2), if you open the Platform.kt under that source
set, you'll see that it is in fact
shared/src/androidMain/kotlin/com/example/myapplication/Platform.kt.
[Android Studio] Chipmunk fixes this issue.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文