Tencent / MMKV

An efficient, small mobile key-value storage framework developed by WeChat. Works on Android, iOS, macOS, Windows, and POSIX.
Other
17.3k stars 1.9k forks source link

UnsatisfiedLinkError with 1.3.5 and 1.3.6. No issues when using 1.3.4 #1342

Closed dimitar71 closed 2 months ago

dimitar71 commented 3 months ago

Note:

An crash issue will be ignored & closed in a week without logs.

The language of MMKV

Kotlin

The version of MMKV

1.3.5 and 1.3.6

The platform of MMKV

Android

The installation of MMKV

Gradle/Maven

What's the issue?

With 1.3.5 and 1.3.6 I am getting java.lang.UnsatisfiedLinkError: dlopen failed: library "libmmkv.so" not found

We are using with multi process mode, here is the line where it fails:

private val mmkv: MMKV = MMKV.initialize(appContext).run { MMKV.mmkvWithID(MMKV_FILE_NAME, MMKV.MULTI_PROCESS_MODE) }

Note that there are no such issues when using 1.3.4.

What's the log of MMKV when that happened?

Here is the exception we are getting, happens when app starts

FirebaseCrashlytics             I  No version control information found
WM-WrkMgrInitializer            D  Initializing WorkManager with default configuration.
WM-PackageManagerHelper         D  Skipping component enablement for androidx.work.impl.background.systemjob.SystemJobService
WM-Schedulers                   D  Created SystemJobScheduler and enabled SystemJobService
CompatibilityChangeReporter     D  Compat change id reported: 160794467; UID 10031; state: ENABLED
[Koin]                          I  Started 59 definitions in 8.056186 ms
MMKV                            I  Enable checkProcessMode()
AndroidRuntime                  D  Shutting down VM
AndroidRuntime                  E  FATAL EXCEPTION: main
                                   Process: com.telus.stbtvclient, PID: 19533
                                   java.lang.UnsatisfiedLinkError: dlopen failed: library "libmmkv.so" not found
                                    at java.lang.Runtime.loadLibrary0(Runtime.java:1077)
                                    at java.lang.Runtime.loadLibrary0(Runtime.java:998)
                                    at java.lang.System.loadLibrary(System.java:1656)
                                    at com.tencent.mmkv.MMKV.doInitialize(MMKV.java:226)
                                    at com.tencent.mmkv.MMKV.initialize(MMKV.java:208)
                                    at com.tencent.mmkv.MMKV.initialize(MMKV.java:94)
                                    at org.koin.core.instance.InstanceFactory.create(InstanceFactory.kt:50)
                                    at org.koin.core.instance.SingleInstanceFactory.create(SingleInstanceFactory.kt:46)
                                    at org.koin.core.instance.SingleInstanceFactory$get$1.invoke(SingleInstanceFactory.kt:55)
                                    at org.koin.core.instance.SingleInstanceFactory$get$1.invoke(SingleInstanceFactory.kt:53)
                                    at org.koin.mp.KoinPlatformTools.synchronized(KoinPlatformTools.kt:36)
                                    at org.koin.core.instance.SingleInstanceFactory.get(SingleInstanceFactory.kt:53)
                                    at org.koin.core.registry.InstanceRegistry.resolveInstance$koin_core(InstanceRegistry.kt:109)
                                    at org.koin.core.scope.Scope.resolveValue(Scope.kt:248)
                                    at org.koin.core.scope.Scope.resolveInstance(Scope.kt:234)
                                    at org.koin.core.scope.Scope.get(Scope.kt:21)
FirebaseCrashlytics             W  Unable to read App Quality Sessions session id.
Process                         I  Sending signal. PID: 19533 SIG: 9
jzlhll commented 3 months ago

1.3.5+ drop x86 and armV7.

lingol commented 3 months ago

1.3.5+ drop x86 and armV7.

That is right. You have two options. Either add armv8 support or build armv7 binary of MMKV by yourself.

dimitar71 commented 3 months ago

Thank you for your quick responses. I am going to do that and will inform here of the success/failure.

Using it in a library module, we are expecting this to work out of the box. It is failing when compiling against a vanilla Chromecast device after all, not some exotic unknown thingie done in a mom-and-pop basement/garage.

Or, to have a short tutorial/steps what needs to be done - with or w/o building from sources and alike. I personally think there should be an extensive section somewhere there - https://github.com/Tencent/MMKV/wiki/android_setup, with screenshots and all.

Other than this recent problem - an excellent, if not best and in its own league, library.

And finally, a suggestion - if possible, to have arm.. .so part of Assets section of every new release? It will help a lot!

dimitar71 commented 3 months ago

OK, using the steps in https://github.com/Tencent/MMKV/wiki/android_setup > Build From source and it fails.

Using Android Studio Koala | 2024.1.1.

Please provide full steps guide if possible, including Android Studio version, Gradle version, Java version, etc. for the ability to compile against your sources.

In the meantime, back to 1.3.4.

This is using default project:

Screenshot 2024-07-06 at 11 23 50 AM

And this is after upgrading Gradle to 7.5

Screenshot 2024-07-06 at 3 43 20 PM
dimitar71 commented 3 months ago

After some tweaking, I could build from sources using latest Android Studio, Gradle and Kotlin. There are some caveats, up to you to use these findings or not.

Attached is MMKV-1.3.6/Android/MMKV folder only as a zip, with the changes which allow me to build and use all arm additions.


Everything from Android/MMKV folder

Prepare and Build

Changes

MMKV-1.3.6.zip

lingol commented 3 months ago

The removal of 32bit architecture is a well thought decision and will not be reversed.

Upon your changes, the changes to the abi filter is essential. Others are just environmental differences.

I shall mention the steps to build a armv7 binary in the wiki if I haven't already done so.

lingol commented 2 months ago

v1.3.7 LTS has just been release.

This Long Term Support (LTS) release primarily reintroduces support for the ARMv7 architecture and lowers the minimum SDK version requirement to 21. Please note that only critical bug fixes will be applied to the 1.3.x series.

New features will be introduced in version 2.0 and later, which will discontinue support for 32-bit architectures and raise the minimum SDK version requirement to 23.

lingol commented 2 months ago

One more thing, the wiki has been updated on building from source on Android. It will be helpful once we upgrade to v2.0+. https://github.com/Tencent/MMKV/wiki/android_setup

dimitar71 commented 2 months ago

Thank you!