Hi đ Is there a possibility for keeping resources(strings, dimens, colors) in the common module and then used in shared Compose compositions that are kept in commonMain?
It seems you are right, despite the fact that it is labeled as âMultiplatformâ. Only the API seems to be multi-platform but not the underlying mechanism. So you canât share the actual resources in some common fashion. Please correct me if I am wrong.
What are the relevant platforms for you then? In my case (only Android and Desktop) I just use the good old Java way of storing and retrieving resources. That still works on Android too although it is not very common.
y
ynsok
02/21/2022, 2:45 PM
Iâm also writing application on Android and Desktop. Do you have any samples or resources on how can I achieve the same approach?
m
Michael Paus
02/21/2022, 3:00 PM
I just created a folder âresourcesâ under âcommonMainâ and put all common resources in there. I also have âresourcesâ folders under âdesktopMainâ and âandroidMainâ for platform specific resources like, e.g., âMETA-INF/services/some service declarationâ. You can then access these via the usual Java mechanisms, e.g.:
Copy code
SomeClass::class.java.getResource(resourceName)
Note! This works only as long as you restrict yourself to the Java world!