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

Error during Android compile #280

Closed
r1si opened this issue Jan 7, 2022 · 6 comments
Closed

Error during Android compile #280

r1si opened this issue Jan 7, 2022 · 6 comments

Comments

@r1si
Copy link

r1si commented Jan 7, 2022

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
Copy link
Author

r1si commented Jan 7, 2022

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
Copy link
Author

r1si commented Jan 7, 2022

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!

@mrousavy
Copy link
Owner

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

@r1si
Copy link
Author

r1si commented Jan 10, 2022

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

@IreNadee
Copy link

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

@mrousavy
Copy link
Owner

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

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

3 participants