Hello,
I'm encountering a problem using the "by" keyword for my composable's states.
I have a module where it works perfectly and second one where it always indicates "Property delegate must have a 'getValue(Nothing?, KProperty0<*>)".
I've tried with a basic property such as:
Copy code
val test by remember { mutableSetOf(false) }
and a state like this:
Copy code
val state by viewModel.state.collectAsStateWithLifecycle()
I've also tried to clean and rebuild the project as well as cleaning Android Studio's cache.
Anyone has any idea where this might came from?
I can share more info about my gradle files or import if necessary.
Wish you all a good day!
Alexis
04/12/2025, 4:00 PM
Well, I've found a solution, it seems that the following import
import androidx.compose.runtime.getValue
was missing, but I don't understand why the IDE didn't imported as usual...
👍 1
f
Fernando
04/12/2025, 4:54 PM
Hey, Alexis.
Yeah, that seems to be a common problem some times, and the IDE doesn't flag you that, but by importing the
getValue
(and
setValue
for mutable variables) should get fixed
✅ 1
a
Alexis
04/12/2025, 4:58 PM
Yes, it fixed it, since it's the first time it happens to me I was really puzzled, but next time I'll check the imports in the first place 🙂
f
francisco
04/14/2025, 7:29 PM
Is there a way to have android studio auto import those?
a
Alexis
04/15/2025, 7:31 AM
It usually works like fine with the IDE import suggestions, but for some reason, this time it wasn't...
Maybe related to my version of the IDE: 2024.3.2 RC 2