-
Type: Improvement
-
Resolution: Done
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
How frequently does the bug occur?
Always
Description
When I developing Android App with the Realm Kotlin SDK, specify a path to the Realm database through the following code
val config = RealmConfiguration.Builder(schema = setOf(Dog::class))
.directory(SystemConstant.DBFolder)
.name("Test.realm")
.build()
In the above code, SystemConstant.DBFolder refers to the path of the external storege card. I confirm that the Android program has obtained the write permission of the external storege card
Realm also created some files in the directory, I thought maybe this is a bug? Realm Kotlin does not allow database file creation on external storege cards?
Stacktrace & log output
Unable to find source-code formatter for language: shell. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
FATAL EXCEPTION: main Process: com.navinfo.volvo, PID: 15616 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.navinfo.volvo/com.navinfo.volvo.ui.MainActivity}: java.lang.IllegalArgumentException: Could not open Realm with the given configuration: path=/storage/emulated/0/Android/data/com.navinfo.volvo/files/log/Test.realm name=Test.realm maxNumberOfActiveVersions=9223372036854775807 schemaVersion=0 schemaMode=RLM_SCHEMA_MODE_AUTOMATIC schema=[class com.navinfo.volvo.model.Dog]: RealmCoreException([2]: Read-only file system) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3764) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3938) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:106) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2282) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loopOnce(Looper.java:211) at android.os.Looper.loop(Looper.java:300) at android.app.ActivityThread.main(ActivityThread.java:8258) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:556) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1049) Caused by: java.lang.IllegalArgumentException: Could not open Realm with the given configuration: path=/storage/emulated/0/Android/data/com.navinfo.volvo/files/log/Test.realm name=Test.realm maxNumberOfActiveVersions=9223372036854775807 schemaVersion=0 schemaMode=RLM_SCHEMA_MODE_AUTOMATIC schema=[class com.navinfo.volvo.model.Dog]: RealmCoreException([2]: Read-only file system) at io.realm.kotlin.internal.CoreExceptionConverter.genericRealmCoreExceptionHandler(RealmInteropBridge.kt:165) at io.realm.kotlin.internal.CoreExceptionConverter.convertToPublicException(RealmInteropBridge.kt:137) at io.realm.kotlin.internal.CoreExceptionConverter.convertToPublicException$default(RealmInteropBridge.kt:127) at io.realm.kotlin.internal.RealmImpl$Companion.create$io_realm_kotlin_library(RealmImpl.kt:298) at io.realm.kotlin.Realm$Companion.open(Realm.kt:82) at com.navinfo.volvo.ui.MainActivity$onCreate$1.onGranted(MainActivity.kt:77) at com.hjq.permissions.IPermissionInterceptor.grantedPermissionRequest(IPermissionInterceptor.java:43) at com.hjq.permissions.XXPermissions.request(XXPermissions.java:197) at com.navinfo.volvo.ui.MainActivity.onCreate(MainActivity.kt:61) at android.app.Activity.performCreate(Activity.java:8305) at android.app.Activity.performCreate(Activity.java:8269) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1374) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3744) ... 12 more Caused by: io.realm.kotlin.internal.interop.RealmCoreOtherException: [2]: Read-only file system at io.realm.kotlin.internal.interop.CoreErrorUtils.coreErrorAsThrowable(CoreErrorUtils.kt:28) at io.realm.kotlin.internal.interop.realmcJNI.open_realm_with_scheduler(Native Method) at io.realm.kotlin.internal.interop.realmc.open_realm_with_scheduler(realmc.java:1703) at io.realm.kotlin.internal.interop.RealmInterop.realm_open(RealmInterop.kt:193) at io.realm.kotlin.internal.interop.RealmInterop.realm_open$default(RealmInterop.kt:181) at io.realm.kotlin.internal.ConfigurationImpl.openRealm$suspendImpl(ConfigurationImpl.kt:105) at io.realm.kotlin.internal.ConfigurationImpl.openRealm(Unknown Source:0) at io.realm.kotlin.internal.RealmImpl$1.invokeSuspend(RealmImpl.kt:121) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:284) 2023-04-04 16:19:19.729 15616-15616 AndroidRuntime com.navinfo.volvo E 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:118) at io.realm.kotlin.internal.RealmImpl.<init>(Unknown Source:0) at io.realm.kotlin.internal.RealmImpl$Companion.create$io_realm_kotlin_library(RealmImpl.kt:296) ... 21 more
Can you reproduce the bug?
Always
Reproduction Steps
https://github.com/xiaoyan159/RealmTest/tree/realm
branch: realm
Version
1.6.1
What Atlas App Services are you using?
Local Database only
Are you using encryption?
Yes
Platform OS and version(s)
Android 12
Build environment
Android Studio version: 2021.3.1
Android Build Tools version: 30.0.3
Gradle version: 7.4