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

查看:155
本文介绍了空的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 构建它-错误.没有完整的描述,只有失败任务的名称-将kotlin编译为ios arm64 .全新项目中的错误.我尝试重建项目-没运气.因此,我重新启动了Studio,魔术的第二部分开始了.

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并重建
  • 重新启动笔记本电脑
  • 更新所有插件等

伙计们,您有任何想法如何使Studio只与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天全站免登陆