I recently cloned a React Native project repository, and I’m encountering an issue when trying to run the app on an Android device/emulator. After cloning the repository, I ran the necessary installation steps and confirmed that my development environment is set up correctly, but when I attempt to run the app using npm run android
, I encounter the following error:
Steps to Reproduce:
- Clone the repository:
git clone <repo_url>
- Navigate to the project directory.
- Run
npm install
to install dependencies. - Run
npm run android
.
Output when running npm run android
:
> [email protected] android
> react-native run-android
info A dev server is already running for this project on port 8081.
info Installing the app...
info 💡 Tip: Make sure that you have set up your development environment correctly, by running npx react-native doctor.
:ReactNative:Running '[node, D:CodeINTERNNCoRidercorider-hybrid-applicationnode_modules@react-native-communityclibuildbin.js, config]' command failed.
FAILURE: Build failed with an exception.
* Where:
Script 'D:CodeINTERNNCoRidercorider-hybrid-applicationnode_modules@react-native-communitycli-platform-androidnative_modules.gradle' line: 401
* What went wrong:
A problem occurred evaluating script.
> Process 'command 'node'' finished with non-zero exit value 1
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.
BUILD FAILED in 1s
error Failed to install the app. Command failed with exit code 1: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
:ReactNative:Running '[node, D:CodeINTERNNCoRidercorider-hybrid-applicationnode_modules@react-native-communityclibuildbin.js, config]' command failed. FAILURE: Build failed with an exception. * Where: Script 'D:CodeINTERNNCoRidercorider-hybrid-applicationnode_modules@react-native-communitycli-platform-androidnative_modules.gradle' line: 401 * What went wrong: A problem occurred evaluating script. > Process 'command 'node'' finished with non-zero exit value 1 * Try: > Run with --stacktrace option to get the stack trace. > Run with --info or --debug option to get more log output. > Run with --scan to get full insights. > Get more help at https://help.gradle.org. BUILD FAILED in 1s.
info Run CLI with --verbose flag for more details.
Troubleshooting Steps Taken:
-
I ran
npx react-native doctor
to verify the setup, and the output shows everything is configured correctly:Common ✓ Node.js - Required to execute JavaScript code ✓ npm - Required to install NPM dependencies ✓ Metro - Required for bundling the JavaScript code Android ✓ Adb - Required to verify if the android device is attached correctly ✓ JDK - Required to compile Java code ✓ Android Studio - Required for building and installing your app on Android ✓ ANDROID_HOME - Environment variable that points to your Android SDK installation ✓ Gradlew - Build tool required for Android builds ✓ Android SDK - Required for building and installing your app on Android Errors: 0 Warnings: 0
-
I tried running the build with
--stacktrace
,--info
, and--verbose
flags, but the issue persists with no additional insight.
Additional Information:
- React Native version: 0.74.5 (from package.json)
- React version: 18.2.0
- Node.js version: 18.x.x
- npm version: 10.8.2
- OS: Windows 11
- Android Studio: Installed and configured correctly, with SDKs and Emulators available.
What I’ve Tried:
- I confirmed that
node
andnpm
are installed and working correctly. - I deleted
node_modules
and rannpm install
again. - I’ve tried cleaning the Gradle build cache using
gradlew clean
but still facing the same issue.
What Should I Do Next?
Any help on resolving this issue would be appreciated. Is there any specific configuration or missing setup I need to check? I’m also curious if there are any known issues related to this native_modules.gradle
file for this version of React Native.