Realm-java: Realm is crashing on "Realm.init()" due to a missing "librealm-jni.so" that the documentation does not mention

Created on 6 Apr 2017  Â·  10Comments  Â·  Source: realm/realm-java

Goal

Initialize realm in my activity

Expected Results

Activity starts successfully (it does not crash)

Actual Results

App crash with the following stacktrace

```E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.asoriba.android.nfcadmin.debug, PID: 8035
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.asoriba.android.nfcadmin.debug/com.asoriba.android.nfcadmin.ui.BiometricReaderActivity}: com.getkeepsafe.relinker.MissingLibraryException: lib/armeabi/librealm-jni.so
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java)
at android.app.ActivityThread.access$800(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java)
at android.os.Handler.dispatchMessage(Handler.java)
at android.os.Looper.loop(Looper.java)
at android.app.ActivityThread.main(ActivityThread.java)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java)
Caused by: com.getkeepsafe.relinker.MissingLibraryException: lib/armeabi/librealm-jni.so
at com.getkeepsafe.relinker.ApkLibraryInstaller.installLibrary(ApkLibraryInstaller.java:85)
at com.getkeepsafe.relinker.ReLinkerInstance.loadLibraryInternal(ReLinkerInstance.java:180)
at com.getkeepsafe.relinker.ReLinkerInstance.loadLibrary(ReLinkerInstance.java:136)
at com.getkeepsafe.relinker.ReLinker.loadLibrary(ReLinker.java:70)
at com.getkeepsafe.relinker.ReLinker.loadLibrary(ReLinker.java:57)
at io.realm.internal.RealmCore.loadLibrary(RealmCore.java:60)
at io.realm.Realm.init(Realm.java:189)
at com.asoriba.android.nfcadmin.ui.BiometricReaderActivity.onCreate(BiometricReaderActivity.java:67)
at android.app.Activity.performCreate(Activity.java)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java) 
at android.app.ActivityThread.access$800(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java) 
at android.os.Handler.dispatchMessage(Handler.java) 
at android.os.Looper.loop(Looper.java) 
at android.app.ActivityThread.main(ActivityThread.java) 
at java.lang.reflect.Method.invoke(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:372) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java) 

#### Steps & Code to Reproduce

1. Follow instructions on [Realm Getting Started Docs](https://realm.io/docs/java/latest/#getting-started)

2. Run app

#### Code Sample

This is my actual code. The line with `Realm.init()` is crashing

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

    kvStoreClient = new KVStoreClient(BiometricReaderActivity.this);
    Realm.init(BiometricReaderActivity.this);
    setContentView(R.layout.activity_biometric_reader);

```

Version of Realm and tooling

Realm version(s): 3.1.0

Realm sync feature enabled: no

Android Studio version: Android Studio 2.4 Preview 4
Build #AI-171.3870562, built on March 31, 2017
JRE: 1.8.0_112-release-b736 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o

Which Android version and device: HTC One

T-Help

All 10 comments

Do you use any other libraries which contains a armeabi so file?

Hey, thanks for the quick response!
Yes, I'm building an app that works with a fingerprint scanner.
screen shot 2017-04-06 at 08 27 54

I checked one previous issue that suggested adding this to my build.gradle file. I've just done that, but the problem still persists.
screen shot 2017-04-06 at 08 28 06

realm removed the armeabi support since v2.0.0 because of some compiling issues and there are actually no devices only support armeabi but not armeabi-v7a.

Does the fingerprint scanner also have armeabi-v7a so files? if yes, you can simple exclude those armeabi so files from that lib.

It doesn't support armeabi-v7a. Then I won't be able to use Realm 😕

I think it is actually fine if you move all fingerprint scanner so files to aremeabi-v7a together with realm so files, or vice versa ... See https://groups.google.com/forum/#!topic/android-ndk/oeytf5C0A28

As long as the apk is not running on a very old device which doesn't support armeabi-v7a (i don't think there are any in the real market)

But Realm should supply an armeabi so file. See #3506

@beeender Yes, this worked! Thank you 🙂

I have a question ,why don't you supply an armeabi/librealm-jni.so?
My program that has own armeabi/lib-jni.so which use to encrypt something .
Then use the realm , there is MissingLibraryException: lib/armeabi/librealm-jni.so.
I copy this so files from armeabi to armeabi-v7a ,run the app, there is java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList......couldn't find "lib-jni.so" .
So, it makes me some trouble.

@koukoucai is armeabi/lib-jni.so from a 3rd party lib or it is built from your JNI source code?

just 3rd party lib .

@koukoucai can you share you apk with us? to [email protected]

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yuwu picture yuwu  Â·  3Comments

cmelchior picture cmelchior  Â·  3Comments

pawlo2102 picture pawlo2102  Â·  3Comments

wezley98 picture wezley98  Â·  3Comments

Merlin1993 picture Merlin1993  Â·  3Comments