Docs Menu

Troubleshooting - Android SDK

On this page

  • Couldn't load "librealm-jni.so"
  • Network Calls to Mixpanel
  • Change Listeners in Android 12 with SDK Versions Below 10.5.1
  • Configurations Cannot be Different if Used to Open the Same File

If your app uses native libraries that don’t ship with support for 64-bit architectures, Android will fail to load Realm’s librealm-jni.so file on ARM64 devices. This happens because Android cannot load 32-bit and 64-bit native libraries concurrently. Ideally, all libraries could provide the same set of supported ABIs, but sometimes that may not be doable when using a 3rd-party library.

To work around this issue, you can exclude Realm’s ARM64 library from the APK file by adding the following code to the application’s build.gradle. You can refer to Mixing 32- and 64-bit Dependencies in Android for more information.

android {
//...
packagingOptions {
exclude "lib/arm64-v8a/librealm-jni.so"
}
//...
}
Tip
See also:

Realm collects anonymous analytics when you run the Realm bytecode transformer on your source code. This is completely anonymous and helps us improve the product by flagging:

  • which version of the SDK you use
  • which operating system you use
  • if your application uses Kotlin
  • if your application uses local-only Realm Database or Realm Sync

Analytics do not run when your application runs on user devices - only when you compile your source code. To opt out of analytics, you can set the REALM_DISABLE_ANALYTICS environment variable to true.

Due to an update to Linux kernel 5.x, object, collection, and realm notifications do not work in SDK versions below 10.5.1 on emulated devices running Android 12. For full functionality in Android 12, update to SDK version 10.5.1.

Realm Database runs checks whenever you open a realm file to avoid corruption. In order to avoid accidentally opening a realm file with incompatible settings, the SDK uses Java's equals() method to compare RealmConfiguration objects. This prevents the SDK from opening a single realm file with different schemas, durability levels, or writability settings. However, configurations that include lambda functions, such as those passed to initialData() and compactOnLaunch(), can break this equals() comparison, since two different lambdas are never considered equal using Java's built-in comparison. To avoid this error when using lambdas, you can either:

  1. Store a single configuration statically in your application, so that separate realm instances use the exact same RealmConfiguration object and it passes the check.
  2. Override the default equals check of the RealmConfiguration:

    val config = RealmConfiguration.Builder()
    .initialData(object: Realm.Transaction {
    override fun execute(realm: Realm) {
    TODO("Not yet implemented")
    }
    override fun equals(other: Any?): Boolean {
    return true
    }
    override fun hashCode(): Int {
    return 37
    }
    }).build()
Give Feedback
© 2021 MongoDB, Inc.

About

  • Careers
  • Legal Notices
  • Privacy Notices
  • Security Information
  • Trust Center
© 2021 MongoDB, Inc.