空的 KMM 项目卡住了 gradle 同步 [英] Empty KMM project is stuck with gradle sync

查看:34
本文介绍了空的 KMM 项目卡住了 gradle 同步的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将一些业务逻辑从我的 iOS 应用转移到 KMM.当突然开始在工作室遇到问题时,我已经做了一些工作.它没有构建,有奇怪的 metaspace 错误等.老实说,我在我的项目周围跳动了几个小时和几天 - 没有结果.我决定完全卸载 Studio 及其所有依赖文件.

I am trying to move some business logic from my iOS apps to KMM. I have already made some job when suddenly started having problems with studio. It was not building, there were weird metaspace errors, etc. I was beating around my project for several hours and days to be honest - no result. I decided to completely uninstall studio and all its dependent files.

在那之后,我什至无法正确构建一个空的 KMM 项目.简单的 Android 项目很好.只有 KMM 才会出现问题.当我第一次创建项目时,它已成功加载,下载所有依赖项并同步.我能够看到Android"项目结构.我试图通过 ./gradlew build 构建它 - 错误.没有完整的描述,只有失败任务的名称——compile kotlin to ios arm64.一个全新项目中的错误.我尝试重建项目 - 没有运气.所以我重新启动了工作室,魔法的第二部分开始了.

After that I'm not even able to properly build an empty KMM project. Simple Android projects work just fine. Problems occur only with KMM. When I have created a project for the first time, it has loaded successfully, downloaded all the dependencies and synced. I was able to see "Android" project structure. I tried to build it via ./gradlew build - error. There was no complete description, only the name of the failed task - compile kotlin to ios arm64. An error in a completely new project. I tried rebuilding project - no luck. So I restarted studio and here the second part of magic begins.

从这一刻起,每当我打开一个新的或现有的 KMM 项目时,它就会开始同步并卡住.例如,我无法打开项目结构,因为正在进行同步,我无法添加依赖项,因为正在进行同步.但是我可以通过 ./gradlew build 构建它并且它构建了!好吧,我尝试了更多命令,例如 ./gradlew -refresh-dependencies 等.它构建成功.然后在某个时候所有的代码都变成了红色.下面可以同时看到Android Studio的所有颜色:

From this moment whenever I open a new or existing KMM project, it starts syncing and stucks. I can't open project structure for example, because sync is in progress, I can't add dependencies, because sync is in progress. But I can build it via ./gradlew build and it builds! Well, I tried some more commands, like ./gradlew -refresh-dependencies etc. It was building successfully. And then at some point all the code became red. Below you can see all the colors of Android Studio at the same time:

在终端中可以看到构建成功.在右下角,您可以看到它不允许进入项目结构,因为正在进行同步.最美丽的就是那些未解决的符号.

In the terminal you can see that it was built successfully. In the lower right corner you can see that it doesn't allow to go to the project structure because of sync in progress. And the most beautiful are all that unresolved symbols.

我相信我已经尝试了大部分 Android Studio 的东西:

I believe I have tried the most of these Android Studio things:

  • 使缓存无效重启
  • 只需重新启动
  • 重建项目
  • ./gradlew clean build
  • 删除 ~/.gradle 和 ./gradle 并重建
  • 重新启动笔记本电脑
  • 更新所有插件等

伙计们,你们有什么想法可以让工作室只与 KMM 一起工作吗?然后我应该如何让它继续工作?正如我已经说过的,问题不是特定于工作室的,而是特定于 KMM 的,因为常规的 android 项目构建得很好.

Guys, do you have any ideas how can I make studio just work with KMM? And then how should I make it keep working? As I've already said, the problem is not studio specific, it is KMM specific, because regular android projects build just fine.

Android Studio 4.1.2

Mac OS Big Sur 11.2

Kotlin 1.4.30-release-Studio4.1-1

推荐答案

我猜你遇到过 这个问题.

实际上我不知道如何解决它,但您可以尝试 AS 4.2-beta,因为此 AS 版本中似乎不存在此问题.

Actually I didn't figure how to fix it out, but you can try AS 4.2-beta as this issue seems not be present in this AS build.

同样的事情发生在我身上,我切换到 AS 4.2 beta.

The same happend to me and I switch to AS 4.2 beta.

你我唯一的不同是Kotlin版本:我有1.4.21

The only difference between you and me is Kotlin version: I have 1.4.21

更新

原来我在 KMM 插件和 Kolin 版本之间配置错误.

It turned out that I had a misconfiguration between KMM plugin e Kolin version.

AS 4.1 只能与 KMM 插件 0.2.0 和 Kotlin 1.4.20 一起正常工作,而我使用的是 Kotlin 1.4.30.切换回 Kotlin 1.4.20 解决了这个问题.

AS 4.1 should work correctly only with KMM plugin 0.2.0 and Kotlin 1.4.20, I had Kotlin 1.4.30 instead. Switching back to Kotlin 1.4.20 fixed this.

这篇关于空的 KMM 项目卡住了 gradle 同步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆