mrousavy / react-native-mmkv

⚡️ The fastest key/value storage for React Native. ~30x faster than AsyncStorage!

Home Page:https://mrousavy.com

Repository from Github https://github.commrousavy/react-native-mmkvRepository from Github https://github.commrousavy/react-native-mmkv

Upgrading to 1.3.3 creates compile error

alexco2 opened this issue · comments

Hi,
after upgrading to version 1.3.3 I get the following error:

C/C++ debug|armeabi-v7a : CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
JSI_LIB

Donwgrading to 1.3.2 again solves this issue.

the same problem

"react-native": "^0.63.x",
"react-native-mmkv": "^1.3.3",
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-mmkv:generateJsonModelDebug'.
> /home/i/all_work/thera/mobile-thera-app/node_modules/react-native-mmkv/android/CMakeLists.txt : C/C++ debug|armeabi-v7a : CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
  Please set them or make sure they are set and tested correctly in the CMake files:
  JSI_LIB
      linked by target "reactnativemmkv" in directory /home/i/all_work/thera/mobile-thera-app/node_modules/react-native-mmkv/android


Hi! Yeah, MMKV 1.3.3 requires RN 0.66 to build. I will fix this to also make it build for RN 0.65 and below when I find some free time! :)

@mrousavy

"peerDependencies": {
"react": "*",
"react-native": "*"
},

How about removing dirty versions ^^^ and use something valuable >=0.66.0

@mrousavy no stress. I just wanted to report the issue. For me that is not a problem.

Hi! Yeah, MMKV 1.3.3 requires RN 0.66 to build. I will fix this to also make it build for RN 0.65 and below when I find some free time! :)

worked like a charm!

Hi! Yeah, MMKV 1.3.3 requires RN 0.66 to build. I will fix this to also make it build for RN 0.65 and below when I find some free time! :)

Thanks! Upgraded to React Native 0.66 and worked just fine.

Those mere mortals that couldn't upgrade to RN 0.66 are sighing and waiting until the latest react-native-mmkv version will be available for previous RN versions as the latest mster contains important compilation fixes...🐶

Should downgrading to 1.3.1 work for RN 0.64? I don't need the newer features, but I'm locked to RN 0.64 by expo (SDK 43). I downgraded to 1.3.1 after reading this thread and now my error is slightly different. I'm using the config plug linked in the other thread, so I'm not sure what else I might be doing wrong.

> Task :react-native-mmkv:mergeDebugJniLibFolders

> Task :react-native-mmkv:mergeDebugNativeLibs

> Task :react-native-mmkv:stripDebugDebugSymbols

> Task :react-native-mmkv:copyDebugJniLibsProjectOnly

> Task :app:mergeDebugNativeLibs FAILED
[stderr] FAILURE: Build failed with an exception.

[stderr] * What went wrong:

[stderr] Execution failed for task ':app:mergeDebugNativeLibs'.

[stderr] > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade

[stderr]    > More than one file was found with OS independent path 'lib/x86_64/libreactnativejni.so'. If you are using jniLibs and CMake IMPORTED targets, see https://developer.android.com/studio/preview/features#automatic_packaging_of_prebuilt_dependencies_used_by_cmake

EDIT:
I see that my issue is one someone had in react-native-vision-camera and was fixed 5 days ago in this library. Maybe I can cherry pick that fix with patch-package?
EDIT 2:
Yes, by manually updating packagingOptions.excludes in android/build.gradle to its value on master, I solved my issue.

Will this ever get fixed?

@Albermonte

Will this ever get fixed?

As you can read in my previous comment, there is a solution for this problem. Simply use RN 0.66. In said comment, I also said that I will take a look at this when I have some free time. I didn't have free time to fix your issues yet, since I am busy running a company and enjoying life. Instead of rudely asking someone that provides an awesome project for free to fix your issues, why not try to fix it yourself and contribute to the project you are using for free?

This open source software is provided as is, and I even included an Example project (example/) here which works. It also works in all my production apps.

@mrousavy totaly agree. Your work is really bringing react-native forward. Some people do not understand what work is put into these kind of libraries and aparently do not appreciate it. This really is a downside of open-source...
As a gesture, I bought you a coffee :D

@mrousavy All I did was asking if it was going to be fixed becuase there were no new info after almost 2 months and wanted to know if you are still working on this or just ignoring the error because it works on the latest RN version.

Sorry if the message was rude or similar, not my intention.

If you have any idea why it's not working with RN <0.66 I can try to fix it and open a PR.

Cheers

All good, I'm sure it's just the form of communication, hard to tell a tone over the internet.

No, I am not currently investigating this, since react-native-mmkv is as fast as ever and works great in the example/ app here, as well as in 3 apps I am using in production.

If you find a fix that works for you, I am very happy to test your PR if it still works in my apps, and if it does we can get that to master asap. :)

Have a nice weekend y'all

Also, thank you Alex for the Coffee. Much appreciated! 🖤

The issue is here

RN < 0.66 doesn't need that block, while other libraries like react-native-mmkv-storage
use something like this:

if (JSI_LIB)
  # React Native 0.66.x and above
  find_library(
        JSI_LIB
        jsi
        PATHS ${LIBRN_DIR}
        NO_CMAKE_FIND_ROOT_PATH
  )
endif()

That doesn't work here, no idea why, the JSI_LIB var is always empty, so it will only work for RN < 0.66.

I got it working for RN 0.66 with that code but only sometimes, so will use patch-package with RN < 0.66 until a proper fix is found.

If anyone wants it:

react-native-mmkv+1.5.3.patch

diff --git a/node_modules/react-native-mmkv/android/CMakeLists.txt b/node_modules/react-native-mmkv/android/CMakeLists.txt
index 8784d6b..434d8b1 100644
--- a/node_modules/react-native-mmkv/android/CMakeLists.txt
+++ b/node_modules/react-native-mmkv/android/CMakeLists.txt
@@ -31,12 +31,7 @@ find_library(
         log-lib
         log
 )
-find_library(
-        JSI_LIB
-        jsi
-        PATHS ${LIBRN_DIR}
-        NO_CMAKE_FIND_ROOT_PATH
-)
+
 find_library(
         REACT_NATIVE_JNI_LIB
         reactnativejni

Thaks for the solution, @Albermonte