Home > Enterprise >  The supplied javaHome seems to be invalid. I cannot find the java executable. Tried location: C:\Pr
The supplied javaHome seems to be invalid. I cannot find the java executable. Tried location: C:\Pr

Time:10-06

I've been pulling my hair over this for 3 days now,

every time I run the command react-native run-android I get this error:

info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
(node:10284) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
Jetifier found 871 file(s) to forward-jetify. Using 16 workers...
info JS server already running.
info Installing the app...

FAILURE: Build failed with an exception.

* What went wrong:
The supplied javaHome seems to be invalid. I cannot find the java executable. Tried location: C:\Program Files\Java\jdk-17\bin\java.exe

* 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

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build failed with an exception.

* What went wrong:
The supplied javaHome seems to be invalid. I cannot find the java executable. Tried location: C:\Program Files\Java\jdk-17\bin\java.exe

* 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

    at makeError (C:\Users\username\Desktop\code\React Native\Build App\Scheduler\node_modules\execa\index.js:174:9)
    at C:\Users\username\Desktop\code\React Native\Build App\Scheduler\node_modules\execa\index.js:278:16
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async runOnAllDevices (C:\Users\username\Desktop\code\React Native\Build App\Scheduler\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:106:5)
    at async Command.handleAction (C:\Users\username\Desktop\code\React Native\Build App\Scheduler\node_modules\react-native\node_modules\@react-native-community\cli\build\index.js:192:9)info Run CLI with --verbose flag for more details.

I created my directory using basic react-native init projectTesting

My gradle is version 6.9
.\android\gradle\wrapper\gradle-wrapper.properties =>distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-all.zip

My android studios version is Android Studio 2020.3.1

My java version is 15

C:\Users\username>java -version
java version "15" 2020-09-15
Java(TM) SE Runtime Environment (build 15 36-1562)
Java HotSpot(TM) 64-Bit Server VM (build 15 36-1562, mixed mode, sharing)

C:\Users\username>javac -version
javac 15

I was thinking of using java 17 but in the compatibility docs it said:

A Java version between 8 and 15 is required to execute Gradle. Java 16 and later versions are not yet supported when executing Gradle.

any help would be really really appreciated!!

CodePudding user response:

Make sure of your JAVA_HOME Path in your terminal with

echo %JAVA_HOME%

Its a common mistake to have \bin , while \bin should be in the PATH the java home is only your jdk folder like C:\Program Files\Java\jdk-15 .

Deleted the jdk-17 folder and then uninstalled 31 and 30 version of sdk build tools and this should fix the issue .

Glad i helped .

  • Related