Unable to use initialRealmFile with compose multiplatform resources
H4kt opened this issue · comments
How frequently does the bug occur?
Always
Description
Compose multiplatform 1.6.0 introduced native support for resources
Placing a realm file into composeResources/files
and then using it in a real configuration via .initialRealmFile("...")
results in an error that asset file is not found
Stacktrace & log output
Caused by: java.lang.IllegalArgumentException: Asset file not found: 'ral_colors.realm'
at io.realm.kotlin.internal.util.Exceptions.assetFileNotFound(Exceptions.kt:26)
at io.realm.kotlin.internal.platform.SystemUtilsAndroidKt.assetFileAsStream(SystemUtilsAndroid.kt:36)
at io.realm.kotlin.internal.platform.SystemUtilsKt.copyAssetFile(SystemUtils.kt:66)
at io.realm.kotlin.internal.RealmImpl$1.invokeSuspend(RealmImpl.kt:128)
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:280)
at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:85)
at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:59)
at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source:1)
at io.realm.kotlin.internal.platform.CoroutineUtilsSharedJvmKt.runBlocking(CoroutineUtilsSharedJvm.kt:22)
at io.realm.kotlin.internal.platform.CoroutineUtilsSharedJvmKt.runBlocking$default(CoroutineUtilsSharedJvm.kt:21)
at io.realm.kotlin.internal.RealmImpl.<init>(RealmImpl.kt:115)
at io.realm.kotlin.internal.RealmImpl.<init>(Unknown Source:0)
at io.realm.kotlin.internal.RealmImpl$Companion.create$io_realm_kotlin_library(RealmImpl.kt:318)
at io.realm.kotlin.Realm$Companion.open(Realm.kt:83)
at org.koin.core.instance.InstanceFactory.create(InstanceFactory.kt:50)
... 149 more
Caused by: java.io.FileNotFoundException: ral_colors.realm
at android.content.res.AssetManager.nativeOpenAsset(Native Method)
at android.content.res.AssetManager.open(AssetManager.java:904)
at android.content.res.AssetManager.open(AssetManager.java:881)
at io.realm.kotlin.internal.RealmInitializer$Companion.asset(RealmInitializer.kt:36)
at io.realm.kotlin.internal.platform.SystemUtilsAndroidKt.assetFileAsStream(SystemUtilsAndroid.kt:34)
... 167 more
Can you reproduce the bug?
Always
Reproduction Steps
- Setup a compose multiplatform project with compose version 1.6.0 or higher
- Place a realm file into
composeResources/files
- Attempt to use that file as a inital realm file via
.initialRealmFile("...")
Version
1.14.1
What Atlas App Services are you using?
Local Database only
Are you using encryption?
No
Platform OS and version(s)
Android
Build environment
Android Studio version: 2023.2.1
Android Build Tools version: agp 8.2.2
Gradle version: 8.4
➤ PM Bot commented:
Jira ticket: RKOTLIN-1066
This is not an issue with realm, but merely an issue with Compose not putting the resources in platform standard locations as expected by the SDK. It isn't feasible for us to depend on Compose just for the sake of this. We can maybe hope that this will be extracted into a bare non-Compose KMP feature. Alternative you could try to file an issue for Compose to place the resource files where the normal platform frameworks are able to find them.