react-native app error when try and test in emulator(?)



I get this error below whenever I try to test the app after typing the command npx react-native run-android. I tried setting paths in environmental variables. But still doesn’t work I tried reinstalling react-native but still does not work. I tried to reinstall JDK from java but finally, the app still does not run in the emulator. Any feedback is appreciated 🙂

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ‘:react-native-community_masked-view:compileDebugJavaWithJavac’.

Could not find tools.jar. Please check that C:Program FilesJavajre1.8.0_271 contains a valid JDK installation.

  • Try: Run with –stack trace 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 21s

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with –verbose flag for more details. Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081

PS C:vibenote-texting

Answer

I think you need to update your PATH variables.

To set the PATH variable permanently, add the full path of the jdk1.7.0bin directory to the PATH variable. Typically, this full path looks something like C:Program FilesJavajdk1.7.0bin. Set the PATH variable as follows on Microsoft Windows:

Click Start, then Control Panel, then System.

Click Advanced, then Environment Variables.

Add the location of the bin folder of the JDK installation for the PATH variable in System Variables. The following is a typical value for the PATH variable:

C:WINDOWSsystem32;C:WINDOWS;C:Program FilesJavajdk1.7.0bin

From the docs here



Source: stackoverflow