react-native-safe-area-context icon indicating copy to clipboard operation
react-native-safe-area-context copied to clipboard

Build failed: 'react/renderer/components/view/ViewProps.h' file not found

Open GaylordP opened this issue 11 months ago • 18 comments

Hello and thank you for your library! :)

Since yesterday morning, I haven't been able to build my project at all using the command npx react-native run-android. I keep getting this error:

node_modules/react-native-safe-area-context/android/src/main/jni/../../../build/generated/source/codegen/jni/react/renderer/components/safeareacontext/Props.h:12:10: fatal error: 'react/renderer/components/view/ViewProps.h' file not found
#include <react/renderer/components/view/ViewProps.h>

I found a topic about this, but the issue seemed to be resolved (link).

I have tried many times (more than fifteen times) to clear the Yarn, node_modules, and Gradle caches without success.

This issue appeared very suddenly yesterday morning—at 8 AM, everything was working, and by 12 PM, it had stopped working. I didn't modify any dependencies in my project; I simply cleared the caches and node_modules around noon to build a production version.

rm -rf android/.gradle android/.idea android/app/build android/build
rm -rf package-lock.json yarn.lock node_modules
npx react-native start --reset-cache
./android/gradlew clean

Here is my configuration:

  • react-native : 0.76.5
  • react-native-safe-area-context : 5.0.0
  • ndkVersion : 26.1.10909125
  • kotlinVersion : 1.9.24
  • gradle : 8.10.2

react-native info :

System:
  OS: macOS 14.5
  CPU: (8) arm64 Apple M1
  Memory: 99.31 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 22.4.1
    path: /opt/homebrew/bin/node
  Yarn:
    version: 3.6.4
    path: /opt/homebrew/bin/yarn
  npm:
    version: 10.8.1
    path: /opt/homebrew/bin/npm
  Watchman:
    version: 2024.07.15.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /usr/local/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 24.2
      - iOS 18.2
      - macOS 15.2
      - tvOS 18.2
      - visionOS 2.2
      - watchOS 11.2
  Android SDK:
    API Levels:
      - "34"
      - "35"
    Build Tools:
      - 33.0.1
      - 34.0.0
      - 35.0.0
    System Images:
      - android-35 | Google APIs ARM 64 v8a
      - android-35 | Google Play ARM 64 v8a
    Android NDK: Not Found
IDEs:
  Android Studio: 2024.2 AI-242.23339.11.2421.12700392
  Xcode:
    version: 16.2/16C5032a
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.12
    path: /opt/homebrew/opt/openjdk@17/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 15.1.3
    wanted: ^15.1.3
  react:
    installed: 18.3.1
    wanted: ^18.3.1
  react-native:
    installed: 0.76.5
    wanted: 0.76.5
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: true
  newArchEnabled: true

Thank you in advance if you can help me, as I don't have many ideas left to debug this problem.

GaylordP avatar Jan 09 '25 10:01 GaylordP

I have updated lib to version 5.1.0 and this error missed but I have a new one. 'react/renderer/components/view/ViewEventEmitter.h' file not found

ArtemLakhurov avatar Jan 09 '25 10:01 ArtemLakhurov

@ArtemLakhurov I preferred to wait for React Native 0.77 before updating rn-safe-ara-context.

So, you had the same error as me with rn-safe-ara-context 5.0.0, and that’s what motivated you to try the newer version? (If so, that rules out the possibility that the problem is only on my side? ^^)

GaylordP avatar Jan 09 '25 10:01 GaylordP

@GaylordP Yes, But I have two errors on 5.0.0 version.

  1. 'react/renderer/components/view/ViewProps.h' file not found
  2. 'react/renderer/components/view/ViewEventEmitter.h' file not found Also additional details. I have this error only if I use new architecture

ArtemLakhurov avatar Jan 09 '25 10:01 ArtemLakhurov

I encounter an issue only when running the app directly from Android Studio. However, when I run the app using yarn android, the error disappears.

amitkumarcoding avatar Jan 10 '25 15:01 amitkumarcoding

I have the same error. Did anyone solve it?

georgi2005atanasov avatar Jan 13 '25 11:01 georgi2005atanasov

Guys, I think i found the problem. In android/build.gradle you have to explicitly point to the versions of com.android.tools.build:gradle and com.facebook.react:react-native-gradle-plugin. After that while bundling the app will throw exceptions for some libraries. Upgrade them to the latest versions. Now you should be able to build the project successfully. If not please let me know!

georgi2005atanasov avatar Jan 15 '25 11:01 georgi2005atanasov

I am using "react": "18.3.1", "react-native": "0.77.0", "react-native-safe-area-context": "^5.1.0",

when running for IOS i am getting this error and not able to run it at all have been trying it for 2 days now

node_modules/@react-native-community/progress-view/common/cpp/react/renderer/components/progressview/RNCProgressViewState.h:3:10

'react/renderer/components/progressview/Props.h' file not found

Any solutions please... @georgi2005atanasov @ArtemLakhurov @GaylordP

EducoreAPK avatar Jan 31 '25 06:01 EducoreAPK

The problem is within the versions... try to update to the latest ones. Also, if you are using an emulator, It can cause an unexpected behavior.

georgi2005atanasov avatar Feb 03 '25 06:02 georgi2005atanasov

Same issue for me

hai-dct avatar Feb 06 '25 01:02 hai-dct

This is the blocker for us. Anyone have any solution ?

ankitpunchh avatar Feb 14 '25 08:02 ankitpunchh

Could I get someone to try on the latest versions of RN and this library. The original post is correct with needing the gradlew clean and various cache clearing mechanisms. Could you also try gradlew cleanAll?

The issue is probably that React Native hasn't run its codegen step successfully - or it never ran it and doesn't think it has to

jacobp100 avatar Feb 24 '25 21:02 jacobp100

I had this issue out of nowhere, when it had been building just fine before (with the exact same settings). Switching off newArchitecture, building (successful) then turning new architecture on again seemed to fix my version of the issue

finnmerlett avatar Mar 04 '25 10:03 finnmerlett

So most likely a caching issue. Is it only this project, or do other projects exhibit similar issues?

jacobp100 avatar Mar 04 '25 10:03 jacobp100

Got the same problem

bakhiem avatar Mar 13 '25 07:03 bakhiem

I’m not exactly sure why, but I was using [email protected] with @react-native/[email protected]. After downgrading @react-native/gradle-plugin to 0.75.5 to match the React Native version, the build issue was resolved.

bakhiem avatar Apr 16 '25 07:04 bakhiem

Any fix even upgrade safe area context to 5.4.0 (latest) version. Still facing same on iOS ?

ankitpunchh avatar May 06 '25 06:05 ankitpunchh

Check your yarn.lock file for this section react-native@npm:*, it should match your current RN version. (Mine was separate and lower from the version I'm running/upgrading to and was causing the issue)

DrChrispoper avatar Jun 03 '25 08:06 DrChrispoper

For anyone else is still facing this problem. I can confirm @bakhiem 's answer works for me. I update the react-native to 0.78.3 recently to solve the supporting 16Kb Page Size, and I forgot my @react-native/gradle-plugin was still 0.75.5. After change version to 0.78.3 to match the react-native version. I deleted lock files (both package-lock.json and yarn.lock if you are using both). Then delete all the build folder and even .gradle folder (just to make sure everything is clean). I re-run the build and the problem is gone. Couldn't be happier cause i stuck on this for a very long time

I’m not exactly sure why, but I was using [email protected] with @react-native/[email protected]. After downgrading @react-native/gradle-plugin to 0.75.5 to match the React Native version, the build issue was resolved.

anhbuidev avatar Sep 29 '25 16:09 anhbuidev