Closed T-moz closed 3 months ago
I tried to implement this solution. But it didn't worked. https://github.com/Tencent/MMKV/issues/1034#issuecomment-1463559381
Have you tried running the Android native app demo of mmkv which uses a third party library loader, does it work?
I don't have access to the devices you listed above so I'm relying on you to test it.
If the Android native demo runs successfully, you can then make a MethodChannel on the Java side of your project to load libmmkv.so by ReLinker
, await for that call, then call MMKV.initialize()
.
void main() async {
if (Platform.isAndroid) {
await loadLibrayByReLinker('libmmkv.so');
}
// must wait for MMKV to finish initialization
final rootDir = await MMKV.initialize();
print('MMKV for flutter with rootDir = $rootDir');
runApp(MyApp());
}
Have you tried running the Android native app demo of mmkv which uses a third party library loader, does it work?
Thanks for your reply.
The Android native app demo of mmkv also crash on Samsung Galaxy J3:
Logs:
2024-06-04 13:18:33.861 3071-3071 SDAgentPac...teReceiver system_server E Not going to handle 'com.tencent.mmkvdemo'!
2024-06-04 13:18:34.773 3071-3156 system_server system_server E Failed to open APK '/data/app/com.tencent.mmkvdemo-AmRJqrFspyRz7AfzvYoSYQ==/base.apk' I/O error
2024-06-04 13:18:34.773 3071-3156 ResourcesManager system_server E failed to add asset path /data/app/com.tencent.mmkvdemo-AmRJqrFspyRz7AfzvYoSYQ==/base.apk
2024-06-04 13:18:35.494 3071-3071 SDAgentPac...teReceiver system_server E Not going to handle 'com.tencent.mmkvdemo'!
2024-06-04 13:18:36.666 2205-2205 encent.mmkvdem com.tencent.mmkvdemo W Accessing hidden field Landroid/os/Trace;->TRACE_TAG_APP:J (light greylist, reflection)
2024-06-04 13:18:36.667 2205-2205 encent.mmkvdem com.tencent.mmkvdemo W Accessing hidden method Landroid/os/Trace;->isTagEnabled(J)Z (light greylist, reflection)
2024-06-04 13:18:36.740 2205-2205 MMKV com.tencent.mmkvdemo I Enable checkProcessMode()
2024-06-04 13:18:36.998 2205-2205 AndroidRuntime com.tencent.mmkvdemo D Shutting down VM
2024-06-04 13:18:37.005 2205-2205 AndroidRuntime com.tencent.mmkvdemo E FATAL EXCEPTION: main
Process: com.tencent.mmkvdemo, PID: 2205
java.lang.RuntimeException: Unable to create application com.tencent.mmkvdemo.MyApplication: com.getkeepsafe.relinker.MissingLibraryException: Could not find 'libmmkv.so'. Looked for: [armeabi-v7a, armeabi], but only found: [].
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6349)
at android.app.ActivityThread.access$1300(ActivityThread.java:242)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:216)
at android.app.ActivityThread.main(ActivityThread.java:7211)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)
Caused by: com.getkeepsafe.relinker.MissingLibraryException: Could not find 'libmmkv.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:51)
at com.tencent.mmkvdemo.MyApplication$1.loadLibrary(MyApplication.java:23)
at com.tencent.mmkv.MMKV.doInitialize(MMKV.java:221)
at com.tencent.mmkv.MMKV.initialize(MMKV.java:208)
at com.tencent.mmkvdemo.MyApplication.onCreate(MyApplication.java:20)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1158)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6344)
at android.app.ActivityThread.access$1300(ActivityThread.java:242)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:216)
at android.app.ActivityThread.main(ActivityThread.java:7211)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)
2024-06-04 13:18:37.316 2205-2215 System com.tencent.mmkvdemo W A resource failed to call close.
Caused by: com.getkeepsafe.relinker.MissingLibraryException: Could not find 'libmmkv.so'. Looked for: [armeabi-v7a, armeabi], but only found: [].
From v1.3.5, MMKV no longer provides armv7 binary. You have two options.
MMKV 1.3.5 Drop armv7 & x86 support. Use version 1.3.4 to resolve this issue
有点不负责任的感觉。1.3.5开始直接ban掉了,x86和v7a的支持(大概率是这个原因)。从打包后的包解压可以看到,只有arm64-v8a和x64目录里面有库。而1.3.4打包解压后,是4个目录有的。 而如果你是googlePlay发布的话,由于平台又做了cpu架构的区别分发,用户v7a手机下载到的真实程序就没了。 下图是1.3.4打包出来的结果:
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.
Java & Dart
Version 1.3.5
Also reproduced on main.
The platform of MMKV
Flutter Android
The installation of MMKV
Pub dev
What's the issue?
When calling MMKV initialise on an Samsung J3,
DynamicLibrary.open('libmmkv.so')
throw.I've reproduced this issue when running the flutter exemple app from MMKV repo.
This issues seems to appears only on a few old devices. Here is a non exhaustive list of devices.
What's the log of MMKV when that happened?
From firebase:
Logcat: