Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use initialRealmFile with compose multiplatform resources #1719

Closed
H4kt opened this issue Apr 8, 2024 · 2 comments
Closed

Unable to use initialRealmFile with compose multiplatform resources #1719

H4kt opened this issue Apr 8, 2024 · 2 comments

Comments

@H4kt
Copy link

H4kt commented Apr 8, 2024

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

  1. Setup a compose multiplatform project with compose version 1.6.0 or higher
  2. Place a realm file into composeResources/files
  3. 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

Copy link

sync-by-unito bot commented Apr 8, 2024

➤ PM Bot commented:

Jira ticket: RKOTLIN-1066

@rorbech
Copy link
Contributor

rorbech commented Apr 9, 2024

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.

@rorbech rorbech closed this as completed Apr 12, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants