https://kotlinlang.org logo
#compose
Title
# compose
c

CRUD Mehra

03/27/2024, 12:23 PM
How to resolve this issue Unresolved reference: Res
Copy code
Res.drawable.ic_facebook
Unresolved reference: <projectName>.composeapp.generated.resources.*
y

Yves Kalume

03/27/2024, 12:29 PM
Why don’t you use R.drawable ( and make sure you import the correct R)
c

CRUD Mehra

03/27/2024, 12:31 PM
Because I haven't option of R import.
See full code here
d

Dmitry Stakhov

03/27/2024, 1:09 PM
@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

CRUD Mehra

03/27/2024, 1:13 PM
Yes
Compose Multiplatform version
d

Dmitry Stakhov

03/27/2024, 1:14 PM
The
Res
class should be generated automatically, but you can try to call
generateComposeResClass
Gradle task
c

CRUD Mehra

03/27/2024, 1:15 PM
How can I do that?
d

Dmitry Stakhov

03/27/2024, 1:17 PM
Also instead of
<projectName>.composeapp.generated.resources.*
you should use
Copy code
import <projectName>.generated.resources.Res
import <projectName>.generated.resources.ic_facebook
c

CRUD Mehra

03/27/2024, 1:18 PM
See
d

Dmitry Stakhov

03/27/2024, 1:20 PM
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

CRUD Mehra

03/27/2024, 1:26 PM
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

Dmitry Stakhov

03/27/2024, 1:31 PM
Unfortunately I don't have experience with Voyager, so I cannot find the reason why It can affect.
🙌 1
c

CRUD Mehra

03/27/2024, 1:31 PM
Okay No problem and thank you so much for your help
d

Dmitry Stakhov

03/27/2024, 1:33 PM
@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

Ume Channel

03/27/2024, 5:27 PM
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
this only for image i guess
10 Views