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

MissingLibraryException: librealm-jni.so Realm 6.1.0 #6727

Closed
yesidlazaro opened this issue Jan 27, 2020 · 23 comments
Closed

MissingLibraryException: librealm-jni.so Realm 6.1.0 #6727

yesidlazaro opened this issue Jan 27, 2020 · 23 comments

Comments

@yesidlazaro
Copy link

yesidlazaro commented Jan 27, 2020

Goal

init realm calling Realm.init(context)

Actual Results

Caused by: com.getkeepsafe.relinker.MissingLibraryException: Could not find 'librealm-jni.so'. Looked for: [armeabi-v7a, armeabi], but only found: [].
at com.getkeepsafe.relinker.ApkLibraryInstaller.installLibrary(ApkLibraryInstaller.java:173)
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.initializeRealm(Realm.java:322)
at io.realm.Realm.init(Realm.java:265)

looks like the tool is not including the library .so,but if i use the previous version 6.0.2 its works fine. see images

debug apk with realm 6.0.2 android studio 3.5.3 build tools 3.5.3 , device nexus 6 android 6.0.1
alt text

debug apk with realm 6.1.0 android studio 3.5.3 build tools 3.5.3 , device nexus 6 android 6.0.1
alt text

Steps & Code to Reproduce

just call Realm.init method in a your oncreate method of your application class.

Version of Realm and tooling

Realm version(s): 6.1.0

Realm Sync feature enabled: No

Android Studio version: 3.5.3

Android Build Tools version: 3.5.3

Gradle version: 5.4.1

Which Android version and device(s): Nexus 5 with android 6.0.1

@nhachicha
Copy link
Collaborator

The armeabi-v7a shared library is included in the AAR https://bintray.com/realm/maven/download_file?file_path=io%2Frealm%2Frealm-android-library%2F6.1.0%2Frealm-android-library-6.1.0.aar could clean your maven local repository and post your gradle configs?

@yesidlazaro
Copy link
Author

its included but the output apk or .aab is not including it.

@cmelchior
Copy link
Contributor

Sounds like there is a problem in how you are building the app bundle then?

@yesidlazaro
Copy link
Author

i don't think so, in the screenshots above i show whats is the result with a previous version of realm. is like the plugin fails putting the .so for armeabi-v7

@kelvin-lima
Copy link

kelvin-lima commented Feb 26, 2020

Facing Same issue here. Waiting for a solution.

Screen Shot 2020-02-26 at 11 27 19

@kelvin-lima
Copy link

Updating, after generating .aab file, I inspected them and the library is there. After I see on which devices the errors are occurring, all of them are rooted devices. Any other devices still working as expectedly.

@sudokai
Copy link

sudokai commented May 30, 2020

@kelvin-lima How did you solve this?

@kelvin-lima
Copy link

@sudokai as i said, the problem only occurs on Rooted devices. I ignored them and now I'm currently migrating to SQLite+Room, because this bug and some other reasons.

@ianpward
Copy link

hey @kelvin-lima would you mind emailing me at [email protected] - I would love to pick your brain on some of the other reasons that drove you to migrate to SQLite+Room

@ahulyk
Copy link

ahulyk commented Jun 2, 2020

Do we have any updates or workaround?

@yesidlazaro
Copy link
Author

@ahulyk i will close the issue, later 2 weeks i found was a issue in the android studio build tool

@kdotdi
Copy link

kdotdi commented Jul 30, 2020

What kind of issue in the android studio build tool?

@ahulyk
Copy link

ahulyk commented Jul 30, 2020

Still getting this on some devices (Mi 9X android 5.1).
I'm using CI to build app bundle with following config:

com.android.tools.build:gradle:3.6.3
gradle-5.6.4

Any ideas?

@kelvinharron
Copy link

Found one instance of this crash for a user in a release apk, we're stuck on 6.1.0 but did any fixes get pushed for 7.0.0 and up? The librealm-jni-so is present for armeabi-v7a in the apk.

h.f.a.c: Could not find 'librealm-jni.so'. Looked for: [armeabi-v7a, armeabi], but only found: [].
	at com.getkeepsafe.relinker.ApkLibraryInstaller.installLibrary()(ApkLibraryInstaller.java:173)
	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.initializeRealm()(Realm.java:322)
	at io.realm.Realm.init()(Realm.java:265)

Realm version(s): 6.1.0

Realm Sync feature enabled: No

Android Studio version: 4.0.1

Android Build Tools version: 28.0.3

Gradle version: 5.4.1

Which Android version and device(s): Clover C300 with Android 4.4.2

@paktech1
Copy link

paktech1 commented Sep 8, 2020

was facing the same issue, stopped using aab, is the issue fixed on io.realm:realm-gradle-plugin:7.0.0 ? is it safe to use android bundle now ?

@imarindam
Copy link

How to avoid this error for armeabi-v7a? I have users with armeabi-v7a architecture and they are rating 1 star because of this issue. I have uploaded apk instead of bundle but still error not resolved for armeabi-v7a devices.

@paktech1
Copy link

i was able to reduce the apk size by 5mb using split apk,
realm gradle: classpath "io.realm:realm-gradle-plugin:7.0.0-beta-SNAPSHOT"

// APK splitting
splits {
abi {
// Enable APK splitting wrt architecture
enable true

        // Reset the architectures for which you need to build the APKs for
        reset()

        // Include the architectures for which Gradle is building APKs
        include 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a'

        // Set this to false if you don't want an APK that has native code for all architectures
        universalApk false
    }
}

// Assign codes to each architecture
project.ext.versionCodes = ['x86': 0, 'x86_64': 1, 'armeabi-v7a': 2, 'arm64-v8a': 3]

// Add the architecture-specific codes above to base version code, i.e. the version code specified in the defaultConfig{} block
// Example: 2000 is the base version code -> 2000 (x86), 2001 (x86_64), 2002 (armeabi-v7a) & 2003 (arm64-v8a) would be the version codes for the generated APK files
android.applicationVariants.all { variant ->
    variant.outputs.each { output ->
        output.versionCodeOverride = project.ext.versionCodes.get(output.getFilter(com.android.build.OutputFile.ABI), 0) * 1 + android.defaultConfig.versionCode
    }
}

upload apks to developer console x86, x86_64, armeabi-v7a, arm64-v8a respectively.

@CrandellWS
Copy link

I updated from 6.x.x to 10.0.1

Everything seems to be working fine and that error went away

@nolanamy
Copy link

nolanamy commented Sep 3, 2021

Using aab in production; seeing this on both 6.1.0 and 10.4.0.

Of the 65 occurrences in the last 30 days, all were on rooted Android 4.3 devices.

@freakdragon
Copy link

freakdragon commented Mar 30, 2022

Using aab with io.realm:realm-gradle-plugin:10.5.1. Still facing issue in Galaxy M12 Android 11, Galaxy J2 Core Android 8.1.0, POCO X3 Pro Android 12.

Unable to create application aaa.bbb.ccc: eh: Could not find 'librealm-jni.so'. Looked for: [armeabi-v7a, armeabi], but only found: [].

@mujahid-dzinemedia
Copy link

moving to SQLite+Room

@JayasimhaMH
Copy link

I'm using realm in react native app lunching time app is crashing any help me....?

@exaland
Copy link

exaland commented Jan 15, 2024

  1. Go to Realm Website
  2. Click in FAQ
  3. Search "Couldn’t load librealm-jni.so”

You will see update information
TDLR;

In Realm documentation you can find the following:

Couldn’t load “librealm-jni.so” If your app uses other 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 is because Android cannot load 32-bit and 64-bit native libraries concurrently. The best solution would be to have all libraries provide the same set of supported ABIs, but sometimes that may not be doable if you are using a 3rd-party library. See VLC and Realm Library conflicts.

The workaround to this issue is to exclude Realm’s ARM64 library from the APK file by adding the following code to the app’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"
    }
    //...
}

Also, there is a bug with Android Gradle Plugin 1.4.0 betas that leads it to improperly pack .so files included in jar files (see Realm Java issue 1421). To solve this problem, you can revert to Android Gradle Plugin 1.3.0 or use Android Gradle Plugin 1.5.0+.

We are aware of a number of 3rd party libraries, frameworks and management apps which do not have 64-bit support yet:

Parallel Space—but you can advice your users to install the 64 bit version instead. RenderScript—NDK r14 will probably support 64 bit. Unity3d.

Nota: Hello, this is appear again if i'm using proguard on my release buildTypes

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests