Best Practices for integrating react native mmkv into existing Android project
Hi @mrousavy
I have an existing android project, where i have copied the entire react native mmkv folder except MMKV (Submodule ) Which i have listed as a dependency
dependencies { implementation "com.tencent.mmkv:1.3.3" }
I have commented out to execute CMake in build.gradle, during runtime it is not able to find libreactnativemmkv.so
I have tried to extract .so files from .aar file & inlcude them via build.gradle but no luck.
Want to know what is the best way to integrate ? should we copy the entire MMKV folder and place it ?
Guten Tag, Hans here! 🍻
Thanks for your question regarding integrating react-native-mmkv into your existing Android project. It seems you are facing issues with locating libreactnativemmkv.so, but I see that you haven't provided any logs from your runtime or build process. Mrousavy needs those logs to effectively help you out.
To gather logs for Android, you can use adb logcat in your terminal while your app is running. This will give you helpful information about what's going wrong.
Also, keep in mind that for complex integration, you might want to consider copying the entire MMKV folder to ensure everything works smoothly.
If you could provide those logs, we can look into this further!
Note: If you think I made a mistake, please ping
@mrousavyto take a look.
Below is the error.
Error: Exception in HostFunction: java.lang.UnsatisfiedLinkError: dlopen failed: library "libreactnativemmkv.so" not found
I definitely know, i would've missed something.
But i am curious to know if we can rather than copying the entire MMKV folder, can we declare it as dependency in react-native-mmkv/android/build.gradle and refer it.
If we declare it as a dependency it would download .aar file, so can we refer .so file inside it rather than copying it.
I want to know if that is a feasible approach, if not could you please share why ?
Could you please share steps or any readme through which i can achieve this ? @mrousavy
I think this workflow is currently not supported. react-native-mmkv uses MMKV as a submodule / C++ library, to use it from Android you can try to use MMKV's Android bindings, without adding the C++ library twice.