react-native-mmkv icon indicating copy to clipboard operation
react-native-mmkv copied to clipboard

Error during Android compile

Open r1si opened this issue 2 years ago • 5 comments

Hi! today I have installed last version (1.6.2) and follow android installa guide (Without react-native-reanimated) but when try to run the app returns this error:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-mmkv:generateJsonModelDebug'.
> C:\MYPATH\node_modules\react-native-mmkv\android\CMakeLists.txt : C/C++ debug|armeabi-v7a : CMake Error at C:\MYPATH\node_modules\react-native-mmkv\android\CMakeLists.txt:22 (add_library):
    Syntax error in cmake code when parsing string
      C:\MYPATH\node_modules/react-native/ReactCommon/jsi/jsi/jsi.cpp
  
    Invalid character escape '\U'.

Thanks in advance!

r1si avatar Jan 07 '22 15:01 r1si

Ok, I 've found the problem, but I don't know how can I fix for all... in CMakeLists.txt file at line 22: image

As you can see at n.1 will print my PC path describe in n.2

The result is: C:\Users\USER\Documents\GENERIC_PATH\node_modules/react-native/ReactCommon/jsi/jsi/jsi.cpp

to work need to replace " \ " with " / "

the path is inside ${NODE_MODULES_DIR} var.

for now I have paste my direct path C:/Users/USER/Documents/GENERIC_PATH/node_modules/react-native/ReactCommon/jsi/jsi/jsi.cpp and all is work, but is a "FIX" only for my PC....

r1si avatar Jan 07 '22 15:01 r1si

OK :D I have write a replace syntax to normalize path for all PCs 👍

from line 15 replace with this:

if(${REACT_NATIVE_VERSION} LESS 66)
        string(REPLACE "\\" "/" NORMALIZE_PATH ${NODE_MODULES_DIR})
        set (
                INCLUDE_JSI_CPP
                "${NORMALIZE_PATH}/react-native/ReactCommon/jsi/jsi/jsi.cpp"
        )
endif()

add_library(reactnativemmkv  # <-- Library name
        SHARED
        src/main/cpp/cpp-adapter.cpp
        src/main/cpp/MmkvHostObject.cpp
        ${INCLUDE_JSI_CPP} # only on older RN versions
)

And I'll attach full file at this post.

CMakeLists.txt

Can you apply this patch at next release?

Thanks a lot!

r1si avatar Jan 07 '22 15:01 r1si

Hmm, that sucks - is this the typical way paths are handled on windows?

mrousavy avatar Jan 10 '22 09:01 mrousavy

Yes, all paths in windows are with "" not "/"

r1si avatar Jan 10 '22 16:01 r1si

I'm facing the same issue while compiling in windows. Can we get this as a fix?. Thanks

IreNadee avatar Jan 23 '22 01:01 IreNadee

Hey! Sorry I cannot reproduce the issue here and it has been inactive for a while. I am going over issues right now and want to keep the repo clean - so I'm closing this for now, if anyone can post a reproduceable example here I can re-open and take a look :)

mrousavy avatar Jul 17 '23 11:07 mrousavy