Closed atoktoto closed 2 months ago
Did you try to sync the project with Gradle?
Also can you provide archive with the project and tell what version of IDEA/Kotlin plugin are you using?
I've tried to:
The project: https://github.com/atoktoto/compose-experiment (based on a provided desktop template)
Intellj version:
IntelliJ IDEA 2020.2.3 (Ultimate Edition)
Build #IU-202.7660.26, built on October 6, 2020
Subscription is active until December 7, 2020
Runtime version: 11.0.8+10-b944.34 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 10 10.0
GC: ParNew, ConcurrentMarkSweep
Memory: 1979M
Cores: 12
Registry: documentation.show.toolbar=true
Non-Bundled Plugins: org.antlr.intellij.plugin, org.jetbrains.plugins.hocon, org.jetbrains.plugins.vue, io.ktor.intellij.plugin, com.intellij.lang.jsgraphql
Thanks! Reproduced the issue
The same thing happens in Android studio and iirc it's intentional since it's an intrinsic.
The thing is, it makes it hard to understand what is going on without prior experience in Android dev. I finally found the documentation: https://developer.android.com/reference/kotlin/androidx/compose/runtime/package-summary#remember https://developer.android.com/jetpack/compose/state
It also has a kotlin implementation in source code: https://cs.android.com/androidx/platform/frameworks/support/+/androidx-master-dev:compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Remember.kt?q=remember&ss=androidx%2Fplatform%2Fframeworks%2Fsupport:compose%2Fruntime%2Fruntime%2F
I have the same error. Some more information:
and
Treated with replacement
import androidx.compose.runtime.remember
to
import androidx.compose.runtime.*
IDEA version:
IntelliJ IDEA 2020.3 RC (Community Edition)
Build #IC-203.5981.114, built on November 26, 2020
Runtime version: 11.0.9+11-b1145.21 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Linux 5.8.18-1-manjaro
GC: ParNew, ConcurrentMarkSweep
Memory: 977M
Cores: 2
Non-Bundled Plugins: com.atlassian.bitbucket.references, no.tornado.tornadofx.idea
Current Desktop: KDE
(and earlier versions)
Compose v. 0.2.0-build131 and earlier
Construction val a = remember { .... } works fine...
Error "has no method" happened because there are no these imports in the file:
import androidx.compose.runtime.getValue
import androidx.compose.runtime.setValue
getValue/setValue are kotlin delegates needed for "var test by" expression.
IDEA doesn't offer to import them if we wrap mutableStateOf
in remember
, so we have to write them manually.
New Kotlin ticket - https://youtrack.jetbrains.com/issue/KTIJ-20402
Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.
Workaround: add to imports import androidx.compose.runtime.getValue import androidx.compose.runtime.setValue