Uploaded image for project: 'Realm Kotlin'
  1. Realm Kotlin
  2. RKOTLIN-1072

UnsatisfiedLinkError when calling Realm.open

      How frequently does the bug occur?

      Sometimes

      Description

      I have setup realm in one of our module. For some of our users, we are getting this error in our Firebase Crashlytics. App crashes because of this error. I haven't been able to reproduce the issue on my test devices. Although the occurrence of this issue is smaller in number, but app crashes because of it.

      I have setup realm with Hilt.

      @Provides
      @Singleton
      fun providesRealm(): Realm {
          return Realm.open(
              configuration = RealmConfiguration.Builder(
                  schema = setOf(
                      Data::class,
                  )
              ).apply {
                  schemaVersion(2)
                  deleteRealmIfMigrationNeeded()
              }.build()
          )
      }
      

      App crashes when app tries to open Realm.

      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: java.lang.NoClassDefFoundError: io.realm.kotlin.log.RealmLog
             at io.realm.kotlin.Configuration$SharedBuilder.<init>(Configuration.kt:229)
             at io.realm.kotlin.RealmConfiguration$Builder.<init>(RealmConfiguration.kt:53)
             at com.example.android.analytics.data.di.AnalyticsDataModule$Companion.providesRealm(AnalyticsDataModule.kt:101)
             at com.example.android.analytics.data.di.AnalyticsDataModule_Companion_ProvidesRealmFactory.providesRealm(AnalyticsDataModule_Companion_ProvidesRealmFactory.java:35)
             at com.example.android.DaggerMyApplication_HiltComponents_SingletonC$SingletonCImpl$SwitchingProvider.get(DaggerMyApplication_HiltComponents_SingletonC.java:1587)
             at dagger.internal.DoubleCheck.get(DoubleCheck.java:47)
             at com.example.android.DaggerMyApplication_HiltComponents_SingletonC$SingletonCImpl.analyticsRepositoryWithRealmImpl(DaggerMyApplication_HiltComponents_SingletonC.java:1303)
             at com.example.android.DaggerMyApplication_HiltComponents_SingletonC$SingletonCImpl.mapOfAnalyticsRepositoryDestinationAndAnalyticsRepository(DaggerMyApplication_HiltComponents_SingletonC.java:1316)
             at com.example.android.DaggerMyApplication_HiltComponents_SingletonC$SingletonCImpl.-$$Nest$mmapOfAnalyticsRepositoryDestinationAndAnalyticsRepository()
             at com.example.android.DaggerMyApplication_HiltComponents_SingletonC$SingletonCImpl$SwitchingProvider.get(DaggerMyApplication_HiltComponents_SingletonC.java:1572)
             at dagger.internal.DoubleCheck.get(DoubleCheck.java:47)
             at com.example.android.DaggerMyApplication_HiltComponents_SingletonC$SingletonCImpl.ActivityLifecycleCallback(DaggerMyApplication_HiltComponents_SingletonC.java:1320)
             at com.example.android.DaggerMyApplication_HiltComponents_SingletonC$SingletonCImpl.injectMyApplication2(DaggerMyApplication_HiltComponents_SingletonC.java:1545)
             at com.example.android.DaggerMyApplication_HiltComponents_SingletonC$SingletonCImpl.injectMyApplication(DaggerMyApplication_HiltComponents_SingletonC.java:1520)
             at com.example.android.Hilt_MyApplication.hiltInternalInject(Hilt_MyApplication.java:52)
             at com.example.android.Hilt_MyApplication.onCreate(Hilt_MyApplication.java:43)
             at com.example.android.MyApplication.onCreate(MyApplication.kt:25)
             at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1335)
             at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7581)
             at android.app.ActivityThread.-$$Nest$mhandleBindApplication()
             at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2419)
             at android.os.Handler.dispatchMessage(Handler.java:106)
             at android.os.Looper.loopOnce(Looper.java:257)
             at android.os.Looper.loop(Looper.java:368)
             at android.app.ActivityThread.main(ActivityThread.java:8826)
             at java.lang.reflect.Method.invoke(Method.java)
             at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:572)
             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1049)
      
      
      
      Caused by java.lang.UnsatisfiedLinkError: No implementation found for void io.realm.kotlin.internal.interop.realmcJNI.set_log_callback(int, java.lang.Object) (tried Java_io_realm_kotlin_internal_interop_realmcJNI_set_1log_1callback and Java_io_realm_kotlin_internal_interop_realmcJNI_set_1log_1callback__ILjava_lang_Object_2) - is the library loaded, e.g. System.loadLibrary?
             at io.realm.kotlin.internal.interop.realmcJNI.set_log_callback(realmcJNI.java)
             at io.realm.kotlin.internal.interop.realmc.set_log_callback(realmc.java:1729)
             at io.realm.kotlin.internal.interop.RealmInterop.realm_set_log_callback(RealmInterop.kt:1277)
             at io.realm.kotlin.log.RealmLog.<clinit>(RealmLog.kt:49)
             at io.realm.kotlin.Configuration$SharedBuilder.<init>(Configuration.kt:229)
             at io.realm.kotlin.RealmConfiguration$Builder.<init>(RealmConfiguration.kt:53)
             at com.example.android.analytics.data.di.AnalyticsDataModule$Companion.providesRealm(AnalyticsDataModule.kt:101)
             at com.example.android.analytics.data.di.AnalyticsDataModule_Companion_ProvidesRealmFactory.providesRealm(AnalyticsDataModule_Companion_ProvidesRealmFactory.java:35)
             at com.example.android.DaggerMyApplication_HiltComponents_SingletonC$SingletonCImpl$SwitchingProvider.get(DaggerMyApplication_HiltComponents_SingletonC.java:1587)
             at dagger.internal.DoubleCheck.get(DoubleCheck.java:47)
             at com.example.android.DaggerMyApplication_HiltComponents_SingletonC$SingletonCImpl.analyticsRepositoryWithRealmImpl(DaggerMyApplication_HiltComponents_SingletonC.java:1303)
             at com.example.android.DaggerMyApplication_HiltComponents_SingletonC$SingletonCImpl.mapOfAnalyticsRepositoryDestinationAndAnalyticsRepository(DaggerMyApplication_HiltComponents_SingletonC.java:1316)
             at com.example.android.DaggerMyApplication_HiltComponents_SingletonC$SingletonCImpl.-$$Nest$mmapOfAnalyticsRepositoryDestinationAndAnalyticsRepository()
             at com.example.android.DaggerMyApplication_HiltComponents_SingletonC$SingletonCImpl$SwitchingProvider.get(DaggerMyApplication_HiltComponents_SingletonC.java:1572)
             at dagger.internal.DoubleCheck.get(DoubleCheck.java:47)
             at com.example.android.DaggerMyApplication_HiltComponents_SingletonC$SingletonCImpl$SwitchingProvider$1.create(DaggerMyApplication_HiltComponents_SingletonC.java:1618)
             at com.example.android.DaggerMyApplication_HiltComponents_SingletonC$SingletonCImpl$SwitchingProvider$1.create(DaggerMyApplication_HiltComponents_SingletonC.java:1614)
             at androidx.hilt.work.HiltWorkerFactory.createWorker(HiltWorkerFactory.java:57)
             at androidx.work.WorkerFactory.createWorkerWithDefaultFallback(WorkerFactory.java:82)
             at androidx.work.impl.WorkerWrapper.runWorker(WorkerWrapper.java:243)
             at androidx.work.impl.WorkerWrapper.run(WorkerWrapper.java:144)
             at androidx.work.impl.utils.SerialExecutorImpl$Task.run(SerialExecutorImpl.java:96)
             at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
             at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
             at java.lang.Thread.run(Thread.java:1012)
      

      Can you reproduce the bug?

      Sometimes

      Reproduction Steps

      Issue happens for some users. It's also not a device/brand specific issue, as it happens for various brand devices with different android versions as well. App crashes as soon as it loads. Issue happens when initializing Realm.

      Version

      1.13.0

      What Atlas App Services are you using?

      Local Database only

      Are you using encryption?

      No

      Platform OS and version(s)

      Various Android OS versions

      Build environment

      Android Studio version: Android Studio Jellyfish | 2023.3.1 RC 2
      Android Build Tools version: Android SDK Build-Tools 35-rc3
      Gradle version: 8.3.0

            Assignee:
            clemente.tort@mongodb.com Clemente Tort Barbero
            Reporter:
            unitosyncbot Unito Sync Bot
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: