Project scenario:
The mmkv version 1.0.23 used in the project is too old, and 1.0.23 also introduces libc++_shared.so which is about 249K + libmmkv.so which is about 40K.
Checking github, I found that the latest version has reached 1.2.14 and the aar package has been optimized, so I have a need to upgrade.
Problem description
In the project, we upgraded mmkv version 1.0.23 to 1.2.14. After solving a lot of compilation errors (inconsistent kotlin versions, gradle upgrade required, etc.), we thought everything was all right, but we didn’t expect to report the startup
Non-fatal Exception: java.lang.UnsatisfiedLinkError: dlopen failed: library “libmmkv.so” not found
I searched various posts on the Internet – no answer. Later, someone in github issue raised similar questions: dlopen failed: library “libmmkv. so” not found · Issue # 958 · Tencent/MMKV · GitHub
Inspired, we developed the source code GitHub – Tencent/MMKV: An efficient, small mobile key value storage framework by WeChat Works on Android, iOS, macOS, Windows, and POSIX. Clone down and study.
Cause analysis:
After compiling the mmkv module with the source code clone, it is found that only the following four cpu architecture sos will be generated in the compilation log
armeabi-v7a, arm64-v8a, x86, x86_64
No armeabi generated
My own project only supports armeabi
Therefore, the reason is obviously related to the CPU architecture settings of your project.
Why didn’t you compile so to generate armeabi?
The ndk17 does not support armeabi at first. The ndk version needs to be changed to 16 and below and the gradle plug-in needs to be downgraded to 4.1.3 and below. However, the gradle in the project has been upgraded to 7. x
Solution:
Method 1: The app’s build.gradle checks for ndk abiFilters under android-buildTypes
ndk { abiFilters "armeabi" }
Modify to
ndk { abiFilters "armeabi-v7a" }
Armeabi-v7a is backward compatible with armeabi
Method 2: If the project has only armeabi architecture and cannot upgrade to v7a, you can find the armeabi-v7a so through the aar package that mmkv maven depends on, put the so into the project armeabi directory, and the abiFilters can still be “armeabi”.
Read More:
- [Solved] java.lang.UnsatisfiedLinkError: dlopen failed: /lib/arm64/libc++_shared.so not found
- [Easy Solution] flutter Run Error: library “libflutter.so“ not found
- Hive ERROR Failed with exception java.io.IOException:java.lang.IllegalArgumentException
- NestedServletException, Handler dispatch failed; nested exception is java.lang.StackOverflowError [Solved]
- [Solved] Request processing failed; nested exception is java.lang.NullPointerException
- POI Export Excel Error: HTTP Status 500 – Request processing failed; nested exception is java.lang.NullPointerException
- [Solved] swagger3 Error: org.springframework.context.ApplicationContextException: Failed to start bean ‘documentationPluginsBootstrapper’; nested exception is java.lang.NullPointerException
- [Solved] Error: exception: java.lang.reflect.InvocationTargetException: null
- [Maven Error] Exception in thread “main” java.lang.UnsupportedClassVersionError: org/apache/maven/cli/MavenCli : Unsupported major.minor version 51.0
- Win assembleDebug Downloading gradle.zip Error: Exception in thread “main” java.lang.RuntimeException: javax.net.ssl.SSLExce
- ImportError: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.23‘ not found
- Postgis Install Error: could not load library “C:\……“:The specified module could not be found.
- [Solved] Android Error: java.lang.IllegalStateException: Not allowed to start service Intent
- Java.lang.AbstractMethodError: org.mybatis.spring.transaction.SpringManagedTransaction.getTimeout()Ljava/lang/Integer; error resolution
- [Solved] java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/util/ByteArrayBuffer
- How to Solve Error: Android java.lang.IllegalStateException: Could not execute method of the activity
- [ERROR] Terminal initialization failed; falling back to unsupported java.lang.IncompatibleClassChang
- [Solved] Mac VS Code fatal error: ‘bits/stdc++.h‘ file not found
- [Samtools] Run error: error while loading shared libraries: libcrypto.so.1.0.0 or libncurses.so.5 or libtinfow.so.5