Closed RaphaelTarita closed 3 weeks ago
Thanks for report, please make sure that you have Android SDK available.
Thanks for the detailed report!
I checked on this configuration:
And created the project from the multiplatform template:
Can't reproduce errors 1/4/5/6. If setting Android SDK will not help, can you try on a clean configuration of IDEA, without importing the old settings? Or redownload Android SDK, it can be broken.
Errors 3/7 need further investigation, not sure what is the cause.
I tried to "fix" my android SDK but it seems that there was nothing wrong with it. Here are the steps I took:
scoop uninstall android-sdk --purge
to get rid of everything for a new clean installationscoop install android-sdk
)uninstall --purge
and reinstalled to a different location using only Android Studiosdkmanager.bat
)It really seems that this problem is not related to an android sdk problem after all, or I am missing something obvious.
I tried to further investigate the problem and found a little bit of new context:
Error 1 seems to be linked to Error 7 (see the module names). Also it seems really weird that this error appears every time I run "Reload all Gradle Projects". The message tells me that the path duplicate has been taken care of, yet it re-appears on reload.
Error 3 only appears during a fresh gradle build, and never during a gradle project import or a reload. "Fresh" in this case means that the project has not yet been built or that "clean" was run right before.
Error 4 and 5: At first, the file has no error highlighting at all, but after you mark java
directory as sources root, error 5 appears. Additionally, the IDE informs me that Kotlin is not configured for this file. When I then run "Reload all Gradle Projects", that message goes away, BUT the java
directory again gets unmarked as sources root. For some reason, the error highlighting still works.
Error 6: This one really confuses me. I don't understand how the configuration of the androidMain
module differs from the one of desktopMain
so that the actual
declaration of desktopMain
does map to the expect
declaration, but the declaration in androidMain
does not.
Error 7: As previously mentioned, it seems to be linked to Error 1 in some way..
I also noticed two additional "errors" in File -> Project Structure that might provide some more insight:
In the "Modules" menu, the element "test/android/Kotlin" shows the warning "'kotlin' library not found in the module dependencies list". I double-checked that this issue only appears for this module and not for any other module in the list.
In the "Problems" menu, it shows two problems:
1. Library Gradle: org.jetbrains.kotlinx:kotlinx-coroutines-core-metadata:commonMain:1.4.1 has broken classes paths:
D:\dev\test\desktop\build\tmp\kotlinMetadata\jvmMain\implementation\org.jetbrains.kotlinx-kotlinx-coroutines-core-metadata\org.jetbrains.kotlinx-kotlinx-coroutines-core-metadata-commonMain.klib [Fix]
2. Library Gradle: org.jetbrains.kotlinx:kotlinx-coroutines-core-metadata:concurrentMain:1.4.1 has broken classes paths:
D:\dev\test\desktop\build\tmp\kotlinMetadata\jvmMain\implementation\org.jetbrains.kotlinx-kotlinx-coroutines-core-metadata\org.jetbrains.kotlinx-kotlinx-coroutines-core-metadata-concurrentMain.klib [Fix]
I hope all of this can shed more light on the problem! I'm not quite certain what you mean with "try on a clean configuration of IDEA, without importing the old settings". Should I re-install the IDE without referring to my config folder?
Just wanted to add that I just tried this again with a fresh IDE installation. My scoop installation of IntelliJ IDEA Ultimate wasn't properly updating to minor releases, so I re-installed it. But most of the config options and plugins were restored because I have "Settings Sync" activated (tbh that was very convenient).
All the errors persisted just as I have described them at first. For that reason, I can rule out that my IDE installation was broken in some way. What I can not rule out is that the problem is somehow linked to my IDE config and/or plugins. Does anyone know a safe way to revert all config options of IntelliJ to the default options, but being able to switch back to my old config later?
way to revert all config options of IntelliJ to the default options, but being able to switch back to my old config later
To revert IDEA to default state you can just rename %APPDATA%\JetBrains\Idea* folder.
To restore - rename the folder back.
Don't know how it will work with "Settings Sync" though. Probably it should be disabled first.
Okay, so I tried this again. I turned off the settings sync in the IDE, deleted config and system folder, did another clean re-installation, disabled all downloaded plugins and tried to set up the same basic project again. I ran into the same errors again. I don't know what's going on here.
I fixed it.
I did two things and apparently both played a role in resolving the problems.
Firstly, I was still not sure about my Android SDK. I mean I specify its location in the project wizard, but I was still suspicious. Checking my environment variables, it turned out that I only had ANDROID_HOME
(which is deprecated anyway) and ANDROID_SDK_HOME
(which was probably pointing to a wrong location) set. So I deleted those and followed this StackOverflow answer to set all possibly needed envs (except for ANDROID_NDK_ROOT
).
Secondly, I noticed that even though I specified the location of the SDK in the project wizard, it did not show up in Project Structure > SDKs. So I added it manually there.
This, and some re-building and re-importing actually solved the problems.
There are two reasons why I don't think the issue should be closed already:
To retest on plugin 1.5.30
Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.
I hope this is the right place to report this, since the project wizard is technically part of the IntelliJ Kotlin Plugin, but the Compose for Desktop template is only related to this project and not to the kotlin plugin. If I'm wrong here, please redirect me.
The issue is that the "Jetpack Compose for Desktop - Multiplatform" project template produces a new project that already contains multiple errors. Here's a list of steps to reproduce and the errors that appear at the different stages:
-> Error 1: During the Gradle Import, the following warning appears:
-> Error 2: During the Gradle Build, the following warning appears:
-> Error 3: During the following gradle tasks:
:common:compileDebugJavaWithJavac
:android:compileDebugJavaWithJavac
:common:compileReleaseJavaWithJavac
:android:compileReleaseJavaWithJavac
the following warning appears:
-> Error 4: test/android/src/main/java is not marked as Sources Root, therefore Inspections are greatly reduced for this file
-> Error 5: IntelliJ cannot find any of the imports, this causes 10 code errors in total. The imports affected are:
com.example.common.App
android.os.Bundle
androidx.appcompat.app.AppCompatActivity
androidx.compose.ui.platform.setContent
-> Error 6: IntelliJ marks
getPlatformName()
as error because "Actual function 'getPlatformName' has no corresponding expected declaration". Apparently, theexpect
declaration attest/common/src/commonMain/kotlin/com.example.common/platform.kt
is not found.-> Error 7: The directory is not marked as a module root, but instead the two subdirectories "kotlin" and "resources" are marked as module roots and test sources root. The displayed module name for "kotlin" is "androidAndroidTest" and for "resources" it's "androidTest".
As far as I know, those are all errors or weird behaviours that appear in a fresh project from the "Jetpack Compose for Desktop - Multiplatform" template that has not been edited in any way.
I'm quite confused about why I am getting all these problems in a fresh project, moreover I'd like to know how I can fix them. The gradle build seems to work (ignoring the warnings) and the sample desktop application works as expected. However, the unavailable and/or erroneous inspections for android-related modules make it really hard to properly work with Jetpack Compose for Desktop. If the error is somehow related to my configuration (although I mainly sticked to the standard), please tell me how to change it in order to fix the problems.
Environment: