Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Project Wizard is flawed in multiple ways #158

Open
RaphaelTarita opened this issue Dec 1, 2020 · 9 comments
Open

New Project Wizard is flawed in multiple ways #158

RaphaelTarita opened this issue Dec 1, 2020 · 9 comments
Assignees
Labels
bug Something isn't working wizard

Comments

@RaphaelTarita
Copy link

RaphaelTarita commented Dec 1, 2020

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:

  1. File -> New Project -> Kotlin -> Jetpack Compose for Desktop (Experimental) -> Multiplatform
  2. Choose name and location (I'll use test and D:\dev\test for now)
  3. Build System: Gradle Kotlin (only available option)
  4. Project JDK: 15 (I use OpenJDK 15 but I suppose the JDK vendor does not matter)
  5. Artifact Coordinates: Group ID "com.example", Artifact ID "test", Version "1.0"
  6. Click 'Next' and select Android SDK if not detected automatically
  7. Click 'Finish'

-> Error 1: During the Gradle Import, the following warning appears:

Duplicate content roots detected
		Path [D:/dev/test/common/src/androidTest/kotlin] of module [test.common.androidAndroidTest] was removed from modules [test.common.androidTest]
		Also 1 more path was deduplicated. See idea log for details
  1. Wait for the Gradle Import to finish
  2. Go to: Gradle Tool Window -> test/Tasks/build and run "build"

-> Error 2: During the Gradle Build, the following warning appears:

Warning: The 'kotlin-android-extensions' Gradle plugin is deprecated. Please use this migration guide (https://goo.gle/kotlin-android-extensions-deprecation) to start working with View Binding (https://developer.android.com/topic/libraries/view-binding) and the 'kotlin-parcelize' plugin.

-> Error 3: During the following gradle tasks:

  • :common:compileDebugJavaWithJavac
  • :android:compileDebugJavaWithJavac
  • :common:compileReleaseJavaWithJavac
  • :android:compileReleaseJavaWithJavac

the following warning appears:

warning: [options] source value 7 is obsolete and will be removed in a future release
warning: [options] target value 7 is obsolete and will be removed in a future release
  1. Go to: Gradle Tool Window and run "Reload All Gradle Projects" (Errors 1 and 2 will appear again)
  2. Go to: test/android/src/main/java/com/example/android/MainActivity

-> Error 4: test/android/src/main/java is not marked as Sources Root, therefore Inspections are greatly reduced for this file

  1. Mark test/android/src/main/java as "Sources Root"

-> 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
  1. Go to: test/common/src/androidMain/kotlin/com.example.common.platform.kt`

-> Error 6: IntelliJ marks getPlatformName() as error because "Actual function 'getPlatformName' has no corresponding expected declaration". Apparently, the expect declaration at test/common/src/commonMain/kotlin/com.example.common/platform.kt is not found.

  1. Go to: test/common/src/androidTest

-> 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:

  • Windows 10 Pro
  • IntelliJ IDEA Ultimate:
    • IntelliJ IDEA 2020.3 (Ultimate Edition)
    • Build #IU-203.5981.155, built on November 30, 2020
    • Runtime version: 11.0.9+11-b1145.21 amd64
    • VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
    • Windows 10 10.0
    • GC: ParNew, ConcurrentMarkSweep
    • Memory: 8158M
    • Cores: 4
  • Jetpack Compose for Desktop version 0.2.0-build132
  • Kotlin 1.4.20
  • JDK 15 (OpenJDK15)
  • Gradle 6.7.1 (wrapper)
@olonho
Copy link
Contributor

olonho commented Dec 2, 2020

Thanks for report, please make sure that you have Android SDK available.

@igordmn
Copy link
Collaborator

igordmn commented Dec 2, 2020

Thanks for the detailed report!

I checked on this configuration:

  • Windows 10 Pro
  • IntelliJ IDEA 2020.3 (Community Edition)
    • IntelliJ IDEA 2020.3 (Community Edition)
    • Build #IC-203.5981.155, built on December 1, 2020
    • Runtime version: 11.0.9+11-b1145.21 amd64
    • VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
    • Windows 10 10.0
    • GC: ParNew, ConcurrentMarkSweep
    • Memory: 1979M
    • Cores: 16
  • Kotlin 1.4.10/1.4.20 in IDEA plugins
  • JDK 15 (OpenJDK15)

And created the project from the multiplatform template:

  • Compose for Desktop version 0.2.0-build132
  • Kotlin 1.4.20
  • Gradle 6.7.1 (wrapper)

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.

Error 2

Errors 3/7 need further investigation, not sure what is the cause.

@RaphaelTarita
Copy link
Author

I tried to "fix" my android SDK but it seems that there was nothing wrong with it. Here are the steps I took:

  1. Control Test (still the same errors as yesterday)
  2. Checking whether Android Studio or the integrated SDK Manager detects the SDK properly (it does)
  3. I installed my android-sdk via scoop, so I used scoop uninstall android-sdk --purge to get rid of everything for a new clean installation
  4. I checked Android Studio again to see whether it detects another "hidden" SDK somewhere I might have forgotten about (was not the case)
  5. Reinstallation of the Android SDK (scoop install android-sdk)
  6. Again, I checked Android Studio, but it told me that my installation is "incomplete", so I downloaded the rest via Android Studio.
  7. New test of the original issue in IntelliJ IDEA (still the same errors)
  8. I thought that maybe the "incomplete" scoop installation might be a problem so I ran another uninstall --purge and reinstalled to a different location using only Android Studio
  9. Another test of the original issue in IntelliJ. This time I had to manually re-select the sdk location in the project wizard because it had changed. (still the same errors, but this time I got license agreement warnings for android-sdk. I accepted all licenses using sdkmanager.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:

  1. 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.

  2. 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?

@olonho olonho added ide IDE related issue enhancement New feature or request labels Dec 8, 2020
@RaphaelTarita
Copy link
Author

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?

@igordmn
Copy link
Collaborator

igordmn commented Jan 14, 2021

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.

@RaphaelTarita
Copy link
Author

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.

@RaphaelTarita
Copy link
Author

RaphaelTarita commented Jan 15, 2021

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:

  1. I'm not yet entirely sure what caused the problems and how my actions fixed them
  2. I think it would be expected behaviour to register the Android SDK under 'Project Structure > SDKs' when you already specify it in the project wizard. As of now, the SDK location specified in the wizard seems to be barely relevant.

@akurasov akurasov self-assigned this Jul 15, 2021
@akurasov akurasov added wizard and removed ide IDE related issue labels Aug 17, 2021
@akurasov
Copy link
Contributor

To retest on plugin 1.5.30

@akurasov akurasov added bug Something isn't working and removed enhancement New feature or request labels Aug 17, 2021
@akurasov akurasov added the Saved label Nov 1, 2021
@igordmn igordmn removed the Saved label Nov 11, 2022
@okushnikov
Copy link

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working wizard
Projects
None yet
Development

No branches or pull requests

5 participants