react-native-reanimated: Cannot build an app when using Reanimated and V8

Description

When I try to use reanimated 2 with react-native-v8, gradle sync in Android Studio fails with the following error:

Starting Gradle Daemon...
Gradle Daemon started in 1 s 373 ms
> Task :react-native-gradle-plugin:compileKotlin UP-TO-DATE
> Task :react-native-gradle-plugin:compileJava NO-SOURCE
> Task :react-native-gradle-plugin:pluginDescriptors UP-TO-DATE
> Task :react-native-gradle-plugin:processResources UP-TO-DATE
> Task :react-native-gradle-plugin:classes UP-TO-DATE
> Task :react-native-gradle-plugin:inspectClassesForKotlinIC UP-TO-DATE
> Task :react-native-gradle-plugin:jar UP-TO-DATE

> Configure project :react-native-reanimated
Native libs debug enabled: false
Android gradle plugin: 7.2.1
Gradle: 7.5.1
building Reanimated2

> Task :prepareKotlinBuildScriptModel UP-TO-DATE
C/C++: debug|x86 :CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
C/C++: debug|x86 :Please set them or make sure they are set and tested correctly in the CMake files:
C/C++: debug|x86 :V8EXECUTOR_LIB
C/C++: debug|x86 :    linked by target "reanimated" in directory /Users/lukasz.kinasiewicz/dev/reanimatedApp/node_modules/react-native-reanimated/android
C/C++: debug|x86 :CMake Generate step failed.  Build files cannot be regenerated correctly.
[CXX1405] error when building with cmake using /Users/lukasz.kinasiewicz/dev/reanimatedApp/node_modules/react-native-reanimated/android/CMakeLists.txt: Build command failed.
Error while executing process /Users/lukasz.kinasiewicz/Library/Android/sdk/cmake/3.18.1/bin/cmake with arguments {-H/Users/lukasz.kinasiewicz/dev/reanimatedApp/node_modules/react-native-reanimated/android -DCMAKE_SYSTEM_NAME=Android -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_SYSTEM_VERSION=21 -DANDROID_PLATFORM=android-21 -DANDROID_ABI=x86 -DCMAKE_ANDROID_ARCH_ABI=x86 -DANDROID_NDK=/Users/lukasz.kinasiewicz/Library/Android/sdk/ndk/21.4.7075529 -DCMAKE_ANDROID_NDK=/Users/lukasz.kinasiewicz/Library/Android/sdk/ndk/21.4.7075529 -DCMAKE_TOOLCHAIN_FILE=/Users/lukasz.kinasiewicz/Library/Android/sdk/ndk/21.4.7075529/build/cmake/android.toolchain.cmake -DCMAKE_MAKE_PROGRAM=/Users/lukasz.kinasiewicz/Library/Android/sdk/cmake/3.18.1/bin/ninja -DCMAKE_CXX_FLAGS=-fstack-protector-all -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/Users/lukasz.kinasiewicz/dev/reanimatedApp/node_modules/react-native-reanimated/android/build/intermediates/cxx/Debug/591x5v3h/obj/x86 -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=/Users/lukasz.kinasiewicz/dev/reanimatedApp/node_modules/react-native-reanimated/android/build/intermediates/cxx/Debug/591x5v3h/obj/x86 -DCMAKE_BUILD_TYPE=Debug -B/Users/lukasz.kinasiewicz/dev/reanimatedApp/node_modules/react-native-reanimated/android/.cxx/Debug/591x5v3h/x86 -GNinja -DANDROID_STL=c++_shared -DNATIVE_DEBUG=false -DREACT_NATIVE_TARGET_VERSION=70 -DANDROID_TOOLCHAIN=clang -DBOOST_VERSION=1_76_0 -DNODE_MODULES_DIR=/Users/lukasz.kinasiewicz/dev/reanimatedApp/node_modules -DJS_RUNTIME=v8 -DJS_RUNTIME_DIR=/Users/lukasz.kinasiewicz/dev/reanimatedApp/node_modules/react-native-v8 -DCLIENT_SIDE_BUILD=true -DIS_NEW_ARCHITECTURE_ENABLED=false -DPLAYGROUND_APP_NAME=reanimatedApp -DRNVERSION=70}
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Users/lukasz.kinasiewicz/Library/Android/sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Users/lukasz.kinasiewicz/Library/Android/sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done

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:
V8EXECUTOR_LIB
    linked by target "reanimated" in directory /Users/lukasz.kinasiewicz/dev/reanimatedApp/node_modules/react-native-reanimated/android

CMake Generate step failed.  Build files cannot be regenerated correctly.

C/C++: debug|x86 :CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
C/C++: debug|x86 :Please set them or make sure they are set and tested correctly in the CMake files:
C/C++: debug|x86 :FBJNI_LIB
C/C++: debug|x86 :    linked by target "v8executor" in directory /Users/lukasz.kinasiewicz/dev/reanimatedApp/node_modules/react-native-v8/android
C/C++: debug|x86 :FOLLY_LIB
C/C++: debug|x86 :    linked by target "reactnative_internal_static" in directory /Users/lukasz.kinasiewicz/dev/reanimatedApp/node_modules/react-native-v8/android
C/C++: debug|x86 :    linked by target "v8executor" in directory /Users/lukasz.kinasiewicz/dev/reanimatedApp/node_modules/react-native-v8/android
C/C++: debug|x86 :GLOG_LIB
C/C++: debug|x86 :    linked by target "v8executor" in directory /Users/lukasz.kinasiewicz/dev/reanimatedApp/node_modules/react-native-v8/android
C/C++: debug|x86 :JSINSPECTOR_LIB
C/C++: debug|x86 :    linked by target "v8executor" in directory /Users/lukasz.kinasiewicz/dev/reanimatedApp/node_modules/react-native-v8/android
C/C++: debug|x86 :JSI_LIB
C/C++: debug|x86 :    linked by target "v8executor" in directory /Users/lukasz.kinasiewicz/dev/reanimatedApp/node_modules/react-native-v8/android
C/C++: debug|x86 :REACT_NATIVE_JNI_LIB
C/C++: debug|x86 :    linked by target "v8executor" in directory /Users/lukasz.kinasiewicz/dev/reanimatedApp/node_modules/react-native-v8/android
C/C++: debug|x86 :V8_ANDROID_LIB
C/C++: debug|x86 :    linked by target "v8executor" in directory /Users/lukasz.kinasiewicz/dev/reanimatedApp/node_modules/react-native-v8/android
C/C++: debug|x86 :CMake Generate step failed.  Build files cannot be regenerated correctly.
[CXX1405] error when building with cmake using /Users/lukasz.kinasiewicz/dev/reanimatedApp/node_modules/react-native-v8/android/CMakeLists.txt: Build command failed.
Error while executing process /Users/lukasz.kinasiewicz/Library/Android/sdk/cmake/3.18.1/bin/cmake with arguments {-H/Users/lukasz.kinasiewicz/dev/reanimatedApp/node_modules/react-native-v8/android -DCMAKE_SYSTEM_NAME=Android -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_SYSTEM_VERSION=21 -DANDROID_PLATFORM=android-21 -DANDROID_ABI=x86 -DCMAKE_ANDROID_ARCH_ABI=x86 -DANDROID_NDK=/Users/lukasz.kinasiewicz/Library/Android/sdk/ndk/21.4.7075529 -DCMAKE_ANDROID_NDK=/Users/lukasz.kinasiewicz/Library/Android/sdk/ndk/21.4.7075529 -DCMAKE_TOOLCHAIN_FILE=/Users/lukasz.kinasiewicz/Library/Android/sdk/ndk/21.4.7075529/build/cmake/android.toolchain.cmake -DCMAKE_MAKE_PROGRAM=/Users/lukasz.kinasiewicz/Library/Android/sdk/cmake/3.18.1/bin/ninja -DCMAKE_CXX_FLAGS=-fstack-protector-all -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/Users/lukasz.kinasiewicz/dev/reanimatedApp/node_modules/react-native-v8/android/build/intermediates/cxx/Debug/195v332w/obj/x86 -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=/Users/lukasz.kinasiewicz/dev/reanimatedApp/node_modules/react-native-v8/android/build/intermediates/cxx/Debug/195v332w/obj/x86 -DCMAKE_BUILD_TYPE=Debug -B/Users/lukasz.kinasiewicz/dev/reanimatedApp/node_modules/react-native-v8/android/.cxx/Debug/195v332w/x86 -GNinja -DANDROID_STL=c++_shared -DBOOST_VERSION=1_76_0 -DBUILD_DIR=/Users/lukasz.kinasiewicz/dev/reanimatedApp/node_modules/react-native-v8/android/build -DRN_DIR=/Users/lukasz.kinasiewicz/dev/reanimatedApp/node_modules/react-native -DREACT_NATIVE_TARGET_VERSION=70 -DV8_ANDROID_DIR=/Users/lukasz.kinasiewicz/dev/reanimatedApp/node_modules/v8-android-jit -DSO_DIR=/Users/lukasz.kinasiewicz/dev/reanimatedApp/node_modules/react-native-v8/android/build/jniLibs}
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Users/lukasz.kinasiewicz/Library/Android/sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Users/lukasz.kinasiewicz/Library/Android/sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done

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:
FBJNI_LIB
    linked by target "v8executor" in directory /Users/lukasz.kinasiewicz/dev/reanimatedApp/node_modules/react-native-v8/android
FOLLY_LIB
    linked by target "reactnative_internal_static" in directory /Users/lukasz.kinasiewicz/dev/reanimatedApp/node_modules/react-native-v8/android
    linked by target "v8executor" in directory /Users/lukasz.kinasiewicz/dev/reanimatedApp/node_modules/react-native-v8/android
GLOG_LIB
    linked by target "v8executor" in directory /Users/lukasz.kinasiewicz/dev/reanimatedApp/node_modules/react-native-v8/android
JSINSPECTOR_LIB
    linked by target "v8executor" in directory /Users/lukasz.kinasiewicz/dev/reanimatedApp/node_modules/react-native-v8/android
JSI_LIB
    linked by target "v8executor" in directory /Users/lukasz.kinasiewicz/dev/reanimatedApp/node_modules/react-native-v8/android
REACT_NATIVE_JNI_LIB
    linked by target "v8executor" in directory /Users/lukasz.kinasiewicz/dev/reanimatedApp/node_modules/react-native-v8/android
V8_ANDROID_LIB
    linked by target "v8executor" in directory /Users/lukasz.kinasiewicz/dev/reanimatedApp/node_modules/react-native-v8/android

CMake Generate step failed.  Build files cannot be regenerated correctly.


Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.5.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 28s
5 actionable tasks: 5 up-to-date

Steps to reproduce

  1. Clone the linked repo
  2. yarn
  3. yarn start
  4. Open android directory in Android Studio
  5. In Android Studio run Sync project with gradle files - it logs the error mentioned above
  6. In Android Studio run Run app - the application throws an exception due to missing libv8android.so.

Notes:

  1. If I run yarn android the app builds and works properly.
  2. Android Studio version is 2021.2.1 Patch 1

Snack or a link to a repository

https://github.com/lkinasiewicz/reanimatedApp

Reanimated version

2.10.0

React Native version

0.70.0

Platforms

Android

JavaScript runtime

V8

Workflow

No response

Architecture

No response

Build type

No response

Device

No response

Device model

No response

Acknowledgements

Yes

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 15 (7 by maintainers)

Commits related to this issue

Most upvoted comments

Thought I’d drop some data to help everyone out. We use both react-native-reanimated@2.10.0 and react-native-v8@1.4.7 successfully in our project. We have never received any of the errors mentioned.

Here are our versions:

Android Gradle Plugin is 7.0.4
Gradle is 7.3.3
React Native is 0.68.3
Expo (bare) is 45.0.8

buildToolsVersion = "31.0.0"
minSdkVersion = 24
compileSdkVersion = 31
targetSdkVersion = 31
androidxLibVersion = "1.8.0"

In app/build.gradle make sure you have:

project.ext.reanimated = [
        buildFromSource: true
]

Thank you to the authors of both of these plugins. Since the official support landed last month both reanimated and v8 have been working together flawlessly for us at Shipt.

I got the same issue as well. For now I just downgraded to 2.9.1, but looking for a solution for 2.10

@rmdvector or anyone else who is seeing “V8EXECUTOR_LIB” as “NOTFOUND” when running gradle sync, just run a gradle build first.

This is because some heavy lifting tasks for building v8 are done during build time, but they need to be done once for the gradle sync to succeed. (Kudo explains this here)

i’m sorry to introduce the problems for v8 integration. as far as i can tell, there are two issues:

  1. android studio Sync project with gradle files error: android studio will just configure gradle and cmake in this step. however, i have some lazy tasks deferring to gradle execution time. that would make syncing faster, e.g. you may not want to build v8 in this stage. the downside as you seen is the syncing error and the cpp sources are not visible in android studio.

  2. missing libv8android.so when Run: this is a known issue occurred from gradle task dependencies and i’ll try to fix it in the newer react-native-v8 version. in the meantime, you could try to Run again.