ammarahm-ed / react-native-jsi-template

Template library and blog that explain how JSI modules are built from scratch in React Native
https://blog.notesnook.com/getting-started-react-native-jsi/
MIT License
163 stars 24 forks source link

The following variables are used in this project, but they are set to NOTFOUND #1

Closed RichardLindhout closed 3 years ago

RichardLindhout commented 3 years ago

C/C++ debug|x86 : 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: REACT_NATIVE_JNI_LIB linked by target "cpp" in directory /android REACT_NATIVE_UTILS_LIB

ammarahm-ed commented 3 years ago

C/C++ debug|x86 : 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: REACT_NATIVE_JNI_LIB linked by target "cpp" in directory /android REACT_NATIVE_UTILS_LIB

Delete node_modules folder. Run yarn and then run yarn react-native run-android.

If you still face this problem. Let me know your RN version.

Also did this error show up in Android Studio?

RichardLindhout commented 3 years ago

This did show up in android studio when I rebuild library project

RichardLindhout commented 3 years ago

I'm on the latest release candidate of React Native right now

ammarahm-ed commented 3 years ago

This did show up in android studio when I rebuild library project

Run yarn react-native run-android first then rebuild in Android Studio. The aar files are not complied so they are not resolved.

yuri-lomashko-itechart commented 3 years ago

Run yarn react-native run-android first then rebuild in Android Studio

Some CI systems like AppCenter use rebuild command to make build - ./gradlew clean assembleRelease and got that error. Looks like we should have some other solution here

ammarahm-ed commented 3 years ago

Run yarn react-native run-android first then rebuild in Android Studio

Some CI systems like AppCenter use rebuild command to make build - ./gradlew clean assembleRelease and got that error. Looks like we should have some other solution here

The solution is implemented at react-native-mmkv-storage library.

You can look at the source files. android/build.gradle file.

ammarahm-ed commented 3 years ago

Here's how I fixed it:

tasks.whenTaskAdded { task ->
  if (task.name.contains('generateJsonModelDebug') || task.name.contains('externalNativeBuild')) {
    task.dependsOn(extractJNIFiles);
  }

  if (task.name.contains('generateJsonModelRelease')) {
    task.dependsOn(extractJNIFilesForRelease)
  }
}

This is present at the bottom of file here, it's slightly different however you just need to copy the conditions and extractJNIForRelease function

yuri-lomashko-itechart commented 3 years ago

Cool, thanks for answer! I'll check it soon on my side