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

Bogus error messages in IntelliJ IDEA after switching to 1.7.2 #2810

Closed
mipastgt opened this issue Sep 7, 2024 · 10 comments
Closed

Bogus error messages in IntelliJ IDEA after switching to 1.7.2 #2810

mipastgt opened this issue Sep 7, 2024 · 10 comments
Assignees
Labels

Comments

@mipastgt
Copy link

mipastgt commented Sep 7, 2024

Describe the bug
As soon as I switch to version 1.7.2 (from 1.7.1) of org.jetbrains.kotlinx:kotlinx-serialization-json I see bogus error messages in my code like the one in the screen shot below. I call this bogus because neither gradle nor the compiler nor the runtime system seem to have a problem. The code still compiles and runs nicely as before. It's only IntelliJ which seems to be confused. As soon as I switch back to 1.7.1 the error also vanishes. I already tried a complete re-build with deletion of .gradle and .idea but that did not make any difference.

Environment

  • Kotlin version: [e.g. 2.0.20]
  • Kotlin platforms: [e.g. JVM, Android, iOS]
  • Gradle version: [e.g. 8.7]
  • IDE version (if bug is related to the IDE) [IntelliJ IDEA 2024.2.1 (Community Edition)]
  • Other relevant context [e.g. OS version, JRE version, ... ] macOS 14.6.1
Bildschirmfoto 2024-09-07 um 08 58 43
@sandwwraith
Copy link
Member

Can it be connected to #2809? Do you see any errors in Gradle sync?

@mipastgt
Copy link
Author

mipastgt commented Sep 9, 2024

I get the attached output when I change "1.7.1" to "1.7.2" in "libs.versions.toml" and then hit the blue sync icon in IntelliJ IDEA. When I then revert this action and hit the icon again I get no error message. So, by looking at the error message I'd say this is the same cause.
gradle_sync.txt

@sandwwraith
Copy link
Member

Yes, it looks like the same issue. Perhaps you can provide a small reproducer project?

@mipastgt
Copy link
Author

mipastgt commented Sep 9, 2024

I think I found a reproducer. I generated a compose multiplatform project via the Jetbrains wizard. I then added my libs.versions.toml and added several dependencies from my project to this new project. I did not modify any code. Therefore most of the dependencies are not actually used (including serialization) but I still can reproduce this error when I toggle between 1.7.1 and 1.7.2 in the libs.versions.toml. Please let me know if you can reproduce this too.

IdeErrorProject 2.zip

@sandwwraith
Copy link
Member

Thanks, I was finally able to reproduce the issue. It looks like some misunderstanding between Kotlin and Android plugins: if you comment out kotlin { androidTarget { ... }} section, Gradle sync finishes without issues. So for now this problem only affects Kotlin MPP with Android projects. I'll continue investigation and will post updates.

@sandwwraith
Copy link
Member

Also, it seems that releasing the library with Kotlin 2.0.20 altered the Gradle module file, which led to this artifact resolving problems. If I build the library from the same 1.7.2 commit but with Kotlin 2.0.0, a project you've provided syncs without issues.

@mipastgt
Copy link
Author

That seems to indicate a hidden Kotlin or Gradle issue. What are you going to do with it?

@OumaSyuu
Copy link

Im facing the same issue by adding version 1.7.2 to gradle dependencies. But its fine after downgraded to 1.7.1.

@sandwwraith
Copy link
Member

@mipastgt It is most likely a Kotlin Gradle plugin issue, as POMs of kotlinx.serialization 1.7.1 and 1.7.2 have a lot of differences. I've filed https://youtrack.jetbrains.com/issue/KT-71443, and it is likely to be fixed from the Kotlin side. In the meantime, I'll try to workaround this issue in the next kx.serialization release.

sandwwraith added a commit that referenced this issue Sep 17, 2024
…log.

Using explicit versions helps work around the issue where the stdlib version was missing from the POM (https://youtrack.jetbrains.com/issue/KT-71443/Unexpected-POM-file-change-when-updating-from-Kotlin-2.0.0-to-Kotlin-2.0.20).

Also, simplify dependencies' setup since `stdlib-common` does not have to be declared explicitly since 1.9.20 (https://kotlinlang.org/docs/whatsnew1920.html#easier-configuration-of-new-standard-library-versions-in-gradle) and kotlin-test-junit is selected automatically if no other runner is specified (https://kotlinlang.org/docs/gradle-configure-project.html#jvm-variants-of-kotlin-test).

Fixes #2810
@hmy65
Copy link

hmy65 commented Sep 19, 2024

tried kotlin 2.1.0-Beta1 with 1.7.2 for kmp project, still has this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants