How to resolve this issue Unresolved reference: Re...
# compose
c
How to resolve this issue Unresolved reference: Res
Copy code
Res.drawable.ic_facebook
Unresolved reference: <projectName>.composeapp.generated.resources.*
y
Why don’t you use R.drawable ( and make sure you import the correct R)
c
Because I haven't option of R import.
See full code here
d
@Yves Kalume It's a Res from Compose Multiplatform
@CRUD Mehra What is the Compose Multiplatform version? Do you have a
implementation(compose.components.resources)
added to common source set?
c
Yes
Compose Multiplatform version
d
The
Res
class should be generated automatically, but you can try to call
generateComposeResClass
Gradle task
c
How can I do that?
d
Also instead of
<projectName>.composeapp.generated.resources.*
you should use
Copy code
import <projectName>.generated.resources.Res
import <projectName>.generated.resources.ic_facebook
c
See
d
How can I do that?
./gradlew :moduleName:generateComposeResClass
Looks like there is no
motilearn
package in your app, because it's not resolved
Also check the
group
you have mentioned in build.gradle file instead of project name
c
Every thing is works for new project. However, when I sync new libraries
implementation(libs.voyager.navigator)
and
implementation(libs.voyager.screenModel)
,
Res.drawable.ic_google
doesn't work anymore, and it shows an error "Unresolved reference: Res."
@Dmitry Stakhov Thanks you so much your help. I will create a new project from scratch. Let me see if the same error occurs again.
d
Unfortunately I don't have experience with Voyager, so I cannot find the reason why It can affect.
🙌 1
c
Okay No problem and thank you so much for your help
d
@CRUD Mehra If you still have the problem, please feel free to open an issue and attach the minimized project -> https://github.com/JetBrains/compose-multiplatform/issues
u
well, maybe it will fix in near future. Here's an alternative way to achieve it. Just be careful the imageName and imageType - just alternate instead using of Int for resources, change it to String. However, I don't know how to use it in string res
1
this only for image i guess
1