Closed Kashif-E closed 7 months ago
Hi
i have the same problem
how can we generate the Res.kt
class?
@mahramane you are supposed to re-import the project after applying the resources plugin and create the top level composeResources directory with your resources
@Kashif-E can you please help me how can i add resources plugin?
apply the compose plugin after the android https://github.com/Kashif-E/KMPMovies/blob/d389251c26d99591b94048d6568276ca1a61ac7d/MoviesApp/build.gradle.kts#L8 it was fixed already in the master: 3040ea85bbc81cb6d1e22d6928646509ee8b601f
fonts not loading if they are in ttf format only otf is working, what can be the reason for that? @terrakok
GenerateResClassTask was failed:
.DS_Store is not directory! Raw files should be placed in 'composeResources/files' directory.
also i get this error in mac please fix it
@mahramane i have added a comment on the issue you created it will solve it for now
@Kashif-E check your ttf fonts. it should work
Hey @terrakok ill check this in the morning
After updating to 1.6.0-beta1 and migrating resources getting crash in android but iOS working fine.
Crash Log : Process: com.example.app.android, PID: 9465 java.lang.RuntimeException: java.lang.reflect.InvocationTargetException at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:558) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936) Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936) Caused by: org.jetbrains.compose.resources.MissingResourceException: Missing resource with path: drawable/up_icon.xml at org.jetbrains.compose.resources.ResourceReader_jvmAndAndroidKt.readResourceBytes(ResourceReader.jvmAndAndroid.kt:9) at org.jetbrains.compose.resources.ResourceReaderKt$DefaultResourceReader$1.read(ResourceReader.kt:23) at org.jetbrains.compose.resources.ImageResourcesKt$loadImage$2$deferred$1$1$1.invokeSuspend(ImageResources.kt:134) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108) at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:281) at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:85) at kotlinx.coroutines.BuildersKtBuildersKt.runBlocking(Builders.kt:59) at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source:1) at kotlinx.coroutines.BuildersKtBuildersKt.runBlocking$default(Builders.kt:38) at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source:1) at org.jetbrains.compose.resources.ResourceState_blockingKt.rememberResourceState(ResourceState.blocking.kt:15) at org.jetbrains.compose.resources.ImageResourcesKt.vectorResource(ImageResources.kt:99) at org.jetbrains.compose.resources.ImageResourcesKt.painterResource(ImageResources.kt:56) at com.example.app.utility.ImageViewKt.FromLocalDrawable(ImageView.kt:24)
Similar issue here.
Trying to load a font resource from composeResources
fails on Android but works on iOS and Desktop.
After investigating further, it seems like the build process is caching the resources after the first build, and if you add/change the TTF files on composeResources, the next builds use the previously cached resources instead of the new ones.
A workaround is to clean the build files when you change these resources and rebuilding.
I'm not familiar with the code that handles the resources at build time, so I won't be able to to help fixing the code, but I hope this info helps.
Here's a step by step to reproduce and identify the issue:
1) Create a project template with one font (https://terrakok.github.io/Compose-Multiplatform-Wizard/) 2) Do a first build
./gradlew task assembleDebug
3) Check the generated APK
binwalk ./composeApp/build/outputs/apk/debug/composeApp-debug.apk | grep -i ttf
11135653 0xA9EAA5 Zip archive data, v0.0 compressed size: 38709, uncompressed size: 73332, name: assets/font/MyFont-Bold.ttf
4) Add another font (copy/paste the same one with different name), rebuild and check apk. Font is not on APK.
./gradlew task assembleDebug
binwalk ./composeApp/build/outputs/apk/debug/composeApp-debug.apk | grep -i ttf
11135653 0xA9EAA5 Zip archive data, v0.0 compressed size: 38709, uncompressed size: 73332, name: assets/font/MyFont-Bold.ttf
Workaround: 5) Clean, Rebuild and Check
./gradlew task clean
./gradlew task assembleDebug
binwalk ./composeApp/build/outputs/apk/debug/composeApp-debug.apk | grep -i ttf
11135939 0xA9EBC3 Zip archive data, v0.0 compressed size: 38709, uncompressed size: 73332, name: assets/font/MyFont-Bold.ttf
11174705 0xAA8331 Zip archive data, v0.0 compressed size: 38709, uncompressed size: 73332, name: assets/font/MyFont2-Bold.ttf
@nicolasf what a compose version do you use?
[versions]
kotlin = "1.9.23"
compose = "1.6.1"
It was fixed here: https://github.com/JetBrains/compose-multiplatform/commit/c43b64d43a20d155a52bf376c22a34182d583c7a
You can use compose = "1.6.10-dev1523"
or newer
Did a quick test with 1.6.10-dev1561
and it's fixed.
Thanks!
Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.
I updated my project to the latest beta to use the new resources using the generated Res classes i am unable to access and resource. I have tested drawable and fonts and its not a multimodule project.
Affected Platforms.
Versions
To Reproduce Can be reproduced in this branch https://github.com/Kashif-E/KMPMovies/tree/14-remove-seperate-android-app-and-desktop-app
Screenshots
.