Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrading to 1.3.3 creates compile error #177

Closed
alexco2 opened this issue Oct 7, 2021 · 17 comments
Closed

Upgrading to 1.3.3 creates compile error #177

alexco2 opened this issue Oct 7, 2021 · 17 comments

Comments

@alexco2
Copy link

alexco2 commented Oct 7, 2021

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.

@alexco2 alexco2 changed the title Upgrading to 1.3.3 creates comile error Upgrading to 1.3.3 creates compile error Oct 7, 2021
@retyui
Copy link

retyui commented Oct 10, 2021

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


@mrousavy
Copy link
Owner

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! :)

@retyui
Copy link

retyui commented Oct 10, 2021

@mrousavy

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

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

@alexco2
Copy link
Author

alexco2 commented Oct 10, 2021

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

@smali-kazmi
Copy link

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!

@fedeblascofluxit
Copy link

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.

@todorone
Copy link
Contributor

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...🐶

@charles-goode
Copy link

charles-goode commented Oct 26, 2021

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.

@Albermonte
Copy link

Will this ever get fixed?

@mrousavy
Copy link
Owner

mrousavy commented Dec 3, 2021

@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.

@alexco2
Copy link
Author

alexco2 commented Dec 3, 2021

@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

@Albermonte
Copy link

@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

@mrousavy
Copy link
Owner

mrousavy commented Dec 3, 2021

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

@mrousavy
Copy link
Owner

mrousavy commented Dec 3, 2021

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

@Albermonte
Copy link

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

@todorone
Copy link
Contributor

todorone commented Dec 6, 2021

Thaks for the solution, @Albermonte

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants