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

UnsatisfiedLinkError when calling Realm.open #1732

Closed
MSVhora opened this issue Apr 30, 2024 · 7 comments
Closed

UnsatisfiedLinkError when calling Realm.open #1732

MSVhora opened this issue Apr 30, 2024 · 7 comments
Assignees
Labels
Encryption:Off Frequency:Sometimes More-information-needed More information needed from the reporter. The issue will autoclose if no more information is given. Needs-Attention Reporter has responded. Review comment. O-Community Repro:Sometimes SDK-Use:Local T-Bug Waiting-For-Reporter Waiting for more information from the reporter before we can proceed

Comments

@MSVhora
Copy link

MSVhora commented Apr 30, 2024

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

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

Copy link

sync-by-unito bot commented Apr 30, 2024

➤ PM Bot commented:

Jira ticket: RKOTLIN-1072

@clementetb
Copy link
Contributor

For the error it seems that the native component has not been loaded by when you try to initialize the Realm.

I understand that this error appeared when you introduced this new module. Could you share some details on how this module is set up or, even better, a sample project with a setup similar to yours?

@sync-by-unito sync-by-unito bot added the Waiting-For-Reporter Waiting for more information from the reporter before we can proceed label May 3, 2024
@MSVhora
Copy link
Author

MSVhora commented May 4, 2024

Its a usual android multi module setup.

  • Startup Initializers are setup in the project
  • Realm is being used in one of the module, its instance is provided via Hilt

Will create a sample project with similar setup once I get some free time

@github-actions github-actions bot added Needs-Attention Reporter has responded. Review comment. and removed Waiting-For-Reporter Waiting for more information from the reporter before we can proceed labels May 4, 2024
@clementetb
Copy link
Contributor

This report, similar to this one, has been fixed with this workaround.

@MSVhora Could you try adding the following snippet in your App onCreate lifecycle callback?

AppInitializer.getInstance(this)
    .initializeComponent(RealmInitializer::class.java)

@sync-by-unito sync-by-unito bot added Waiting-For-Reporter Waiting for more information from the reporter before we can proceed and removed Needs-Attention Reporter has responded. Review comment. labels May 6, 2024
@nirinchev nirinchev added the More-information-needed More information needed from the reporter. The issue will autoclose if no more information is given. label May 28, 2024
@MSVhora
Copy link
Author

MSVhora commented Jun 8, 2024

Sorry for the late response, I have tried this as well, but still seeing crashes

@github-actions github-actions bot added Needs-Attention Reporter has responded. Review comment. and removed More-information-needed More information needed from the reporter. The issue will autoclose if no more information is given. Waiting-For-Reporter Waiting for more information from the reporter before we can proceed labels Jun 8, 2024
@clementetb
Copy link
Contributor

The issue is with the initializers. Your app is trying to perform some operations on Realm and Realm not being initialized.

Please check the component initialization order. You might find more info in this issue comment.

@sync-by-unito sync-by-unito bot added More-information-needed More information needed from the reporter. The issue will autoclose if no more information is given. Waiting-For-Reporter Waiting for more information from the reporter before we can proceed labels Jun 11, 2024
Copy link
Contributor

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Encryption:Off Frequency:Sometimes More-information-needed More information needed from the reporter. The issue will autoclose if no more information is given. Needs-Attention Reporter has responded. Review comment. O-Community Repro:Sometimes SDK-Use:Local T-Bug Waiting-For-Reporter Waiting for more information from the reporter before we can proceed
Projects
None yet
Development

No branches or pull requests

3 participants