Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
665 views
in Technique[技术] by (71.8m points)

android - Empty KMM project is stuck with gradle sync

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.

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.

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:

enter image description here

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.

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

  • Invalidate cache & restart
  • Just restart
  • Rebuild project
  • ./gradlew clean build
  • Deleting ~/.gradle and ./gradle and rebuild
  • Restarting the laptop
  • Updating all plugins etc.

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I guess you have encounterd this issue.

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.

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

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

UPDATE

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

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...