You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the project I'm working on we try to reduce the nesting of the directories and customized the directory structure:
sourceSets {
val commonMain by getting {
kotlin.apply {
srcDir("commonMain")
resources.srcDir("commonMain/composeResources")
}
// missing code
}
// missing code
What happens is that the Resources accessors (extensions) are not generated, hence we can't do Res.drawable.cupcake and still need to rely on DrawableResource("drawable/copcake.xml").
It would appear that the new compose resources feature relies on the standard structure and does not generate the accessors when that is customized.
Changing the above to the following fixes the issue:
sourceSets {
val commonMain by getting {
kotlin.apply {
srcDir("src/commonMain")
resources.srcDir("src/commonMain/composeResources")
}
// missing code
}
// missing code
Notice the src addition.
Affected platforms
Tested Desktop (Linux) and Android, but I expect it to happen on all
Versions
Kotlin version*: 1.9.23
Compose Multiplatform version*: 1.6.2
OS version(s)* (required for Desktop and iOS issues): Ubuntu 22.04.4 LTS
OS architecture (x86 or arm64): x64
JDK (for desktop issues): Temurin 17.0.6
To Reproduce
Steps and/or the code snippet to reproduce the behavior:
Create a new KMP project and customize the directory structure as above
Add a resource in the composeResources directory
Build the project
Observe Unresolved reference: cupcake
Expected behavior
Resources should be accessible for custom directory structure, as the path to them is provided in the gradle configuration.
The text was updated successfully, but these errors were encountered:
One of the use-cases for this is Compose Resources support in Amper. The current limitation in the Compose Gradle Plugin doesn't allow configuring it for the Amper-native project layout, which uses the flat folders structure. Example:
Describe the bug
In the project I'm working on we try to reduce the nesting of the directories and customized the directory structure:
What happens is that the Resources accessors (extensions) are not generated, hence we can't do
Res.drawable.cupcake
and still need to rely onDrawableResource("drawable/copcake.xml")
.It would appear that the new compose resources feature relies on the standard structure and does not generate the accessors when that is customized.
Changing the above to the following fixes the issue:
Notice the
src
addition.Affected platforms
Versions
To Reproduce
Steps and/or the code snippet to reproduce the behavior:
Unresolved reference: cupcake
Expected behavior
Resources should be accessible for custom directory structure, as the path to them is provided in the gradle configuration.
The text was updated successfully, but these errors were encountered: