Skip to content

Android CMake build fails: "Cannot specify link libraries for target 'react_codegen_lottiereactnative'" with NitroModules and autolinking #56419

@Leo-8991

Description

@Leo-8991

Description

Environment:

React Native version: 0.82 (or your exact version)
Gradle: 8.13
Android NDK: 27.1.12297006
CMake: 3.22.1
NitroModules: enabled
Key native modules: lottie-react-native, react-native-config, react-native-gesture-handler

Description:
After upgrading React Native and enabling NitroModules, the Android build fails with CMake errors related to autolinking and codegen for native modules. All known workarounds (dummy/empty CMakeLists.txt, dummy.cpp, directory creation) have been applied, but the error persists.

Steps to reproduce

  1. Upgrade to React Native 0.82+ with NitroModules enabled.
  2. Add lottie-react-native, react-native-config, and react-native-gesture-handler as dependencies.
  3. Run yarn android or npx react-native run-android.
  4. Observe the build failure.

CMake Error at .../Android-autolinking.cmake:13 (add_subdirectory):
The source directory .../lottie-react-native/android/build/generated/source/codegen/jni
does not contain a CMakeLists.txt file.

CMake Error at .../ReactNative-application.cmake:97 (target_link_libraries):
Cannot specify link libraries for target "react_codegen_lottiereactnative"
which is not built by this project.

Workarounds attempted:
Created dummy/empty CMakeLists.txt and dummy.cpp in all affected codegen/jni folders.
Cleaned all build outputs and re-ran the build.
Tried both dummy and empty CMakeLists.txt files.
The error persists.
Expected behavior:

The build should succeed, or the autolinking system should not emit broken CMake for modules without codegen output.
Additional context:

This appears to be a regression or bug in the autolinking/CMake integration for new architecture builds.

React Native Version

0.82.1

Affected Platforms

Runtime - Android

Output of npx @react-native-community/cli info

System:
  OS: macOS 26.3.1
  CPU: (10) arm64 Apple M4
  Memory: 107.75 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.20.0
    path: /Users/Karthik/.nvm/versions/node/v20.20.0/bin/node
  Yarn:
    version: 1.22.22
    path: /opt/homebrew/bin/yarn
  npm:
    version: 11.12.1
    path: /Users/Karthik/.nvm/versions/node/v20.20.0/bin/npm
  Watchman:
    version: 2026.03.30.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.16.2
    path: /opt/homebrew/lib/ruby/gems/3.4.0/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 25.4
      - iOS 26.4
      - macOS 26.4
      - tvOS 26.4
      - visionOS 26.4
      - watchOS 26.4
  Android SDK:
    API Levels:
      - "33"
      - "34"
      - "35"
      - "36"
    Build Tools:
      - 30.0.3
      - 33.0.2
      - 34.0.0
      - 35.0.0
      - 36.0.0
    System Images:
      - android-35 | Google APIs ARM 64 v8a
      - android-36 | Google Play ARM 64 v8a
      - android-36 | Pre-Release 16 KB Page Size Google Play ARM 64 v8a
    Android NDK: Not Found
IDEs:
  Android Studio: 2025.3 AI-253.31033.145.2533.15113396
  Xcode:
    version: 26.4/17E192
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.18
    path: /opt/homebrew/opt/openjdk@17/bin/javac
  Ruby:
    version: 4.0.2
    path: /opt/homebrew/opt/ruby/bin/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 20.0.0
    wanted: 20.0.0
  react:
    installed: 19.1.1
    wanted: 19.1.1
  react-native:
    installed: 0.82.1
    wanted: 0.82.1
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: true

Stacktrace or Logs

CMake error:

CMake Error at /Users/Karthik/Documents/GitHub/QuitIt/node_modules/lottie-react-native/android/build/generated/source/codegen/jni/CMakeLists.txt:7 (add_library):
  add_library cannot create target "react_codegen_lottiereactnative" because
  another target with the same name already exists. The existing target is a
  static library created in source directory
  "/Users/Karthik/Documents/GitHub/QuitIt/node_modules/lottie-react-native/android/build/generated/source/codegen/jni".
  See documentation for policy CMP0002 for more details.

CMake Error at /Users/Karthik/Documents/GitHub/QuitIt/node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake:97 (target_link_libraries):
  Cannot specify link libraries for target "react_codegen_RNCConfigSpec"
  which is not built by this project.
Call Stack (most recent call first):
  CMakeLists.txt:31 (include)



Gradle exception:

Execution failed for task ':app:configureCMakeDebug[arm64-v8a]'.
> [CXX1429] error when building with cmake using .../CMakeLists.txt: ...
  -- Configuring incomplete, errors occurred!
  See also ".../CMakeFiles/CMakeOutput.log".
  See also ".../CMakeFiles/CMakeError.log".
Caused by: com.android.ide.common.process.ProcessException: Error while executing process .../cmake with arguments {...}
Caused by: org.gradle.process.internal.ExecException: Process 'command .../cmake'' finished with non-zero exit value 1

MANDATORY Reproducer

Failure occurs in my app not RNTester

Screenshots and Videos

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions