one icon indicating copy to clipboard operation
one copied to clipboard

Android Build Fails with React Native Reanimated Codegen Error

Open guillem-aistech opened this issue 7 months ago • 1 comments

Current Behavior

When running one run:android, the build fails with a CMake error related to react-native-reanimated. The error indicates that the codegen directory /node_modules/react-native-reanimated/android/build/generated/source/codegen/jni/ doesn't exist, causing the CMake configuration to fail.

Expected Behavior

The Android build should complete successfully and launch the app on the emulator without CMake errors related to react-native-reanimated codegen files.

One Version

1.1.486

Platform (Web, iOS, Android)

Android (tested on emulator Medium_Phone_API_36.0)

Reproduction

  1. Set up a new OneJS project with react-native-reanimated dependency
  2. Run pnpm --filter @atds/apps-atds android (or one run:android)
  3. Build fails with CMake error during :app:configureCMakeDebug[arm64-v8a] task

Full error output:

> Task :app:configureCMakeDebug[arm64-v8a]
Checking the license for package CMake 3.22.1 in /home/guillem/Android/Sdk/licenses
License for package CMake 3.22.1 accepted.
Preparing "Install CMake 3.22.1 v.3.22.1".
"Install CMake 3.22.1 v.3.22.1" ready.
Installing CMake 3.22.1 in /home/guillem/Android/Sdk/cmake/3.22.1
"Install CMake 3.22.1 v.3.22.1" complete.
"Install CMake 3.22.1 v.3.22.1" finished.
C/C++: CMake Error at /home/guillem/Documents/atds/monorepo/apps/atds/android/app/build/generated/autolinking/src/main/jni/Android-autolinking.cmake:10 (add_subdirectory):
C/C++:   add_subdirectory given source
C/C++:   "/home/guillem/Documents/atds/monorepo/apps/atds/node_modules/react-native-reanimated/android/build/generated/source/codegen/jni/"
C/C++:   which is not an existing directory.
C/C++: Call Stack (most recent call first):
C/C++:   /home/guillem/Documents/atds/monorepo/apps/atds/node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake:100 (include)
C/C++:   CMakeLists.txt:31 (include)
C/C++: CMake Error at /home/guillem/Documents/atds/monorepo/apps/atds/node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake:103 (target_link_libraries):
C/C++:   Cannot specify link libraries for target "react_codegen_rnreanimated" which
C/C++:   is not built by this project.
C/C++: Call Stack (most recent call first):
C/C++:   CMakeLists.txt:31 (include)

> Task :app:configureCMakeDebug[arm64-v8a] FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:configureCMakeDebug[arm64-v8a]'.
> [CXX1429] error when building with cmake using /home/guillem/Documents/atds/monorepo/apps/atds/node_modules/react-native/ReactAndroid/cmake-utils/default-app-setup/CMakeLists.txt

CMake command that failed:

/home/guillem/Android/Sdk/cmake/3.22.1/bin/cmake \
  -H/home/guillem/Documents/atds/monorepo/apps/atds/node_modules/react-native/ReactAndroid/cmake-utils/default-app-setup \
  -DCMAKE_SYSTEM_NAME=Android \
  -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
  -DCMAKE_SYSTEM_VERSION=24 \
  -DANDROID_PLATFORM=android-24 \
  -DANDROID_ABI=arm64-v8a \
  -DCMAKE_ANDROID_ARCH_ABI=arm64-v8a \
  -DANDROID_NDK=/home/guillem/Android/Sdk/ndk/27.1.12297006 \
  -DCMAKE_ANDROID_NDK=/home/guillem/Android/Sdk/ndk/27.1.12297006 \
  -DCMAKE_TOOLCHAIN_FILE=/home/guillem/Android/Sdk/ndk/27.1.12297006/build/cmake/android.toolchain.cmake \
  -DCMAKE_MAKE_PROGRAM=/home/guillem/Android/Sdk/cmake/3.22.1/bin/ninja \
  -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/home/guillem/Documents/atds/monorepo/apps/atds/android/app/build/intermediates/cxx/Debug/34205h14/obj/arm64-v8a \
  -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=/home/guillem/Documents/atds/monorepo/apps/atds/android/app/build/intermediates/cxx/Debug/34205h14/obj/arm64-v8a \
  -DCMAKE_BUILD_TYPE=Debug \
  -DCMAKE_FIND_ROOT_PATH=/home/guillem/Documents/atds/monorepo/apps/atds/android/app/.cxx/Debug/34205h14/prefab/arm64-v8a/prefab \
  -B/home/guillem/Documents/atds/monorepo/apps/atds/android/app/.cxx/Debug/34205h14/arm64-v8a \
  -GNinja \
  -DPROJECT_BUILD_DIR=/home/guillem/Documents/atds/monorepo/apps/atds/android/app/build \
  -DPROJECT_ROOT_DIR=/home/guillem/Documents/atds/monorepo/apps/atds/android \
  -DREACT_ANDROID_DIR=/home/guillem/Documents/atds/monorepo/apps/atds/node_modules/react-native/ReactAndroid \
  -DANDROID_STL=c++_shared \
  -DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON

Attempted fixes that didn't work:

  • Clean build (rm -rf android/app/build android/.gradle android/app/.cxx)
  • Reinstall dependencies (rm -rf node_modules && pnpm install)
  • Running react-native codegen manually
  • Running npx expo prebuild --platform android --clean
  • Running ./gradlew clean in android directory

Environment details:

  • Using pnpm workspace (monorepo setup)
  • Kubuntu 22.04
  • Java 21.0.7 (Temurin via SDKMan)
  • Android SDK with NDK 27.1.12297006
  • CMake 3.22.1 (auto-installed by build process)
  • The missing directory: /node_modules/react-native-reanimated/android/build/generated/source/codegen/jni/

System Info

System:
    OS: Linux 6.14 Ubuntu 25.04 25.04 (Plucky Puffin)
    CPU: (16) x64 AMD Ryzen 7 7735HS with Radeon Graphics
    Memory: 8.72 GB / 30.12 GB
    Container: Yes
    Shell: 5.2.37 - /bin/bash
  Binaries:
    Node: 22.16.0 - ~/.nvm/versions/node/v22.16.0/bin/node
    Yarn: 1.22.22 - ~/.nvm/versions/node/v22.16.0/bin/yarn
    npm: 10.9.2 - ~/.nvm/versions/node/v22.16.0/bin/npm
    pnpm: 10.11.1 - ~/.nvm/versions/node/v22.16.0/bin/pnpm
  Browsers:
    Brave Browser: 137.1.79.119

guillem-aistech avatar Jun 06 '25 14:06 guillem-aistech

It looks like the CMake error is caused by missing codegen output for react-native-reanimated. Try running the following from the android dir:

./gradlew generateCodegenArtifactsFromSchema

This should generate the required jni/ directory and resolve the CMake configuration error.

zetavg avatar Jul 29 '25 20:07 zetavg