Hello everyone! I'm trying to start using resource...
# multiplatform
p
Hello everyone! I'm trying to start using resources instead of hard-coding the values. Currently, I can't do it in:
Copy code
label = { Text(stringResource(resource = Res.string.login)) },
'login' marked red in my AndroidStudio as an unresolved reference. What I already did: 1. create strings.xml file in /composeApp/src/commonMain/composeResources/values/strings.xml:
Copy code
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="login">Ваш логин</string>
</resources>
2. add several imports that may help fix possible dependencies:
Copy code
import org.jetbrains.compose.resources.ExperimentalResourceApi
import kotlinproject.composeapp.generated.resources.Res
import org.jetbrains.compose.resources.StringResource
import org.jetbrains.compose.resources.stringResource
3. See above Am I missing anything? I will be grateful for any ideas provided.
m
You have to build the project at least once for the resources to be generated
1
🙌 1
💯 1
p
1
BTW, my build takes about 2 min and it is considerably long. Is there any other (smaller) task to run to create resources instead of building the whole project?
m
./gradlew composeAppgenerateResourceAccessorsForCommonMain
Got
BUILD SUCCESSFUL in 443ms
when I run it
😄
p
Copy code
BUILD SUCCESSFUL in 141ms
4 actionable tasks: 3 executed, 1 up-to-date

Build Analyzer results available
09:24:10: Execution finished ':composeApp:generateResourceAccessorsForCommonMain'.
😃
Who's faster?..))
Thank you so much!
1
m
no problem 😄