JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
15.02k stars 1.1k forks source link

"androidx dependency" is compiled by a new Kotlin compiler backend and cannot be loaded by the old compiler #61

Closed ggoraa closed 3 years ago

ggoraa commented 3 years ago

Hello,

I created the base project using you getting started tutorial. Well, it runs, it works, but IntelliJ IDEA thinks it should not work. It shows me the error that I specified in the issue name. How can I fix this?

image

igordmn commented 3 years ago

We had similar problem earlier: https://github.com/JetBrains/compose-jb/issues/21

And fixed it with https://github.com/JetBrains/compose-jb/pull/30

(we moved buildscript from settings.gradle.kts to the root build.gradle.kts and the problem was gone)

Do you have buildscript in settings.gradle.kts?

veyndan commented 3 years ago

I'm facing the same issue as @GGorAA, and my settings.gradle.kts is identical to that found in the Getting Started guide:

pluginManagement {
    repositories {
        gradlePluginPortal()
        maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
    }
}
Animeshz commented 3 years ago

Same issue :(

igordmn commented 3 years ago

Can you tell which versions of IDEA and Kotlin IDEA plugin do you use?

If it is possible it would be very helpful if you attach project archive here.

Animeshz commented 3 years ago

Intellij IDEA: 2020.2 Kotlin (plugin): 1.4.10 JB Compose: 0.1.0-m1-build62 JDK Version: 11.0.8 JVM Target: 1.8

subashz commented 3 years ago

Same issue. It happens after creating multiplatform projects from intellij. Intellij IDEA: 2020.3 EAP Runtime version: 11.0.8 VM: Open JDK [64bit]

Repro: https://gofile.io/d/WpJQbh

igordmn commented 3 years ago

Intellij IDEA: 2020.2 Kotlin (plugin): 1.4.10 JB Compose: 0.1.0-m1-build62 JDK Version: 11.0.8 JVM Target: 1.8

Unfortunately I can't reproduce the issue on this configuration. I tried to open these templates: https://github.com/JetBrains/compose-jb/tree/master/templates/desktop-template (which is almost the same as described in https://github.com/JetBrains/compose-jb/tree/master/tutorials/Getting_Started) https://github.com/JetBrains/compose-jb/tree/master/templates/multiplatform-template

Can anyone that have this issue attach archive with project?

Also is there "-Xuse-ir" in Project Settings? image It should be added automatically after the import of the project. If not - will it be added after Gradle Sync? image

subashz commented 3 years ago

Repro: https://gofile.io/d/WpJQbh

Animeshz commented 3 years ago

Strange enough, The same thing happens with the desktop-template project as well when (importing in Intellij).

subashz commented 3 years ago

I don't have any issue with desktop-template based project. It only happens on MPP template for me.

igordmn commented 3 years ago

Repro: https://gofile.io/d/WpJQbh

Multiplatform template from IDEA Wizard currently have this problem (we fixed it in a new version)

Try this: demo.zip

I changed version to "0.1.0-m1-build62" and converted desktop module from kotlin("jvm") to kotlin("multiplatform") (kotlin("jvm") doesn't work well in multiplatform project)

subashz commented 3 years ago

Got new error after tyring to run desktop app,

Repro: https://gofile.io/d/WpJQbh

Multiplatform template from IDEA Wizard currently have this problem (we fixed it in a new version)

Try this: demo.zip

I changed version to "0.1.0-m1-build62" and converted desktop module from kotlin("jvm") to kotlin("multiplatform") (kotlin("jvm") doesn't work well in multiplatform project)

Got new error after trying to run desktop app: Gradle > desktop > Tasks > application > run https://pastebin.com/0MWuepJe

But it works fine if I replace

import me.subash.common.App
import androidx.compose.desktop.Window

fun main() = Window {
    App()
}

with

import androidx.compose.desktop.Window
import androidx.compose.material.Text

fun main() = Window {
    Text("Hello")
}
igordmn commented 3 years ago

Got new error after tyring to run desktop app,

Repro: https://gofile.io/d/WpJQbh

Multiplatform template from IDEA Wizard currently have this problem (we fixed it in a new version) Try this: demo.zip I changed version to "0.1.0-m1-build62" and converted desktop module from kotlin("jvm") to kotlin("multiplatform") (kotlin("jvm") doesn't work well in multiplatform project)

Got new error after trying to run desktop app: Gradle > desktop > Tasks > application > run https://pastebin.com/0MWuepJe

But it works fine if I replace

import me.subash.common.App
import androidx.compose.desktop.Window

fun main() = Window {
    App()
}

with

import androidx.compose.desktop.Window
import androidx.compose.material.Text

fun main() = Window {
    Text("Hello")
}

I forgot to change version in android/build.gradle.kts and common/build.gradle.kts

(you can redownload demo from a comment above, I changed the version)

ggoraa commented 3 years ago

Do you have buildscript in settings.gradle.kts?

I have just copy pasted all code from your getting started guide, and the IDEA just gone wild with errors.

EDIT: I moved pluginManagement part to build.gradle.kts, aaand... Everything just broke. Maybe I misunderstood you :D

ggoraa commented 3 years ago

Multiplatform template from IDEA Wizard currently have this problem (we fixed it in a new version) Try this: demo.zip

Forgot to say, I have the Kotlin/JVM project, not the MPP one

EDIT: Also forgot to say:

Kotlin plugin: 1.4.10 JVM target: 11 JDK: OpenJDK14 IDEA: Latest stable

ggoraa commented 3 years ago

If it is possible it would be very helpful if you attach project archive here.

Easily. https://drive.google.com/file/d/1VRKk64t8z7GwYD6H2bp1hoF6z7nzYqFq/view?usp=sharing

olonho commented 3 years ago

What exactly version of IDEA? 2020.2.3?

X1nto commented 3 years ago

This is what I did to fix the problem: Went into project structure, I had "Use project settings" ticked so I clicked on "Edit project settings" and changed Target JVM Version to 11, then added -Xuse-ir to the command line options, after these operations red lines were gone. Screenshot of my project settings: image

EDIT: I'm using 0.1.0-build113 btw

ggoraa commented 3 years ago

What exactly version of IDEA? 2020.2.3?

yes

ggoraa commented 3 years ago

I upgraded to the latest build of JetBrains Compose plugin, added the command line argument, and it is finally working! No more red lines :D

igordmn commented 3 years ago

If it is possible it would be very helpful if you attach project archive here.

Easily. https://drive.google.com/file/d/1VRKk64t8z7GwYD6H2bp1hoF6z7nzYqFq/view?usp=sharing

I changed the Gradle version from 6.3 to 6.5.1 and red underlining is gone. On Gradle 6.7 and Compose 0.1.0-build113 everything is fine too.

ggoraa commented 3 years ago

I will try this too

ggoraa commented 3 years ago

I also forgot that my target JVM version was 1.6, after the upgrade to 11 every single error is gone

igordmn commented 3 years ago

It seems that everything is ok on the latest Gradle (6.7.1), Compose (0.2.0-build129), Kotlin (1.4.20) and Idea (2020.2.3).

We shouldn't manually add "-Xuse-ir" in project settings. It should be added automatically after Gradle Sync.

So if no one encounters this issue again I think we can close it.

Also if it still an issue, maybe similar changes will help: https://github.com/JetBrains/compose-jb/pull/30/files

steklopod commented 3 years ago

My solution: build.gradle.kts

plugins {
    val kotlin = "1.5.0-M1"
    kotlin("jvm") version kotlin
}
tasks{
            val java: String by project
            withType<KotlinCompile> {
                kotlinOptions { freeCompilerArgs += listOf("-Xskip-prerelease-check", "-Xjsr305=strict"); jvmTarget = java }; sourceCompatibility = java; targetCompatibility = java
            }
}

image