[英]The supplied javaHome seems to be invalid. I cannot find the java executable. Tried location: C:\Program Files\Java\jdk-17\bin\java.exe
I've been pulling my hair over this for 3 days now,我已经为此纠结了 3 天了,
every time I run the command react-native run-android
I get this error:每次我运行命令
react-native run-android
我都会收到此错误:
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
我使用基本
react-native init projectTesting
创建了我的目录
My gradle is version 6.9我的gradle是6.9版本
.\android\gradle\wrapper\gradle-wrapper.properties
=> distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-all.zip
.\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
我的android studios版本是
Android Studio 2020.3.1
My java version is 15我的java版本是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:我正在考虑使用 java 17 但在兼容性文档中它说:
A Java version between 8 and 15 is required to execute Gradle. Java 16 and later versions are not yet supported when executing Gradle.
执行Gradle需要8-15之间的Java版本,执行Gradle还不支持Java 16及以后版本。
any help would be really really appreciated!!任何帮助将不胜感激!
If someone faces this error after Android Studio update to Android Studio Electric Eel |如果有人在 Android Studio 更新到 Android Studio Electric Eel 后遇到此错误 | 2022.1.1 than simply follow following steps:
2022.1.1而不是简单地按照以下步骤操作:
Go To android studio directory (Default C:\Program Files\Android\Android Studio) remove jre folder run cmd as administrator Go 到android studio目录(默认C:\Program Files\Android\Android Studio)删除jre文件夹以管理员身份运行cmd
cd C:\Program Files\Android\Android Studio mklink /D "jre" "jbr" Thanks to this link cd C:\Program Files\Android\Android Studio mklink /D "jre" "jbr" 感谢这个链接
after update to Android Studio 22.1.1, just delete folder jre in C:\Program Files\Android\Android Studio it works for me更新到 Android Studio 22.1.1 后,只需删除 C:\Program Files\Android\Android Studio 中的文件夹 jre 它对我有用
Make sure of your JAVA_HOME Path in your terminal with确保您的终端中的 JAVA_HOME 路径
echo %JAVA_HOME%
The supplied javaHome seems to be invalid.提供的 javaHome 似乎无效。 I cannot find the java executable.
我找不到 java 可执行文件。 Tried location: C:\Program Files\Java\jdk1.8.0_341\bin\java
试过位置:C:\Program Files\Java\jdk1.8.0_341\bin\java
I was in a similar problem and you can solve it in the following way --> Go to Disk C, Find the java folder in android and delete the previous version of jdk by default it comes with 1.8 C:\Program Files\Java for Reac native version 11 of jdk is recommended.我遇到了类似的问题,你可以通过以下方式解决 --> Go 到磁盘 C,找到 android 中的 java 文件夹,删除之前版本的 jdk 默认自带 1.8 C:\Program Files\Java for推荐使用reac native 11版本的jdk。
If someone faces this error after Android Studio update to Android Studio Electric Eel |如果有人在Android Studio 更新到 Android Studio Electric Eel 后遇到此错误 | 2022.1.1 just delete folder jre in C:\Program Files\Android\Android Studio it works for me
2022.1.1只需删除C:\Program Files\Android\Android Studio中的文件夹jre它对我有用
Deleting Java17 SDK and C:\\Program Files\\Java folder worked for me.删除 Java17 SDK 和 C:\\Program Files\\Java 文件夹对我有用。 Use openjdk11 instead of Java17 SDK
使用 openjdk11 代替 Java17 SDK
I faced the problem as I have multiple sdks, eg 1.8 inside my java folder along with java 11. Deleted other jdks except 11 worked for me.我遇到了这个问题,因为我有多个 sdk,例如我的 java 文件夹中的 1.8 以及 java 11。删除了其他 jdk,除了 11 对我有用。
I get help from other answers and with my tries i find this solution:我从其他答案中得到帮助,并通过尝试找到了这个解决方案:
jdk
folder in Android Studio directoryjdk
文件夹 after update to ANDROID STUDIO ELECTRIC EEL, just delete folder jre in (default path)C:\Program Files\Android\Android Studio.更新到 ANDROID STUDIO ELECTRIC EEL 后,只需删除(默认路径)C:\Program Files\Android\Android Studio 中的文件夹 jre。 I had my jre in D:\ANDROID_STUDIO\jre it works for me.
我在 D:\ANDROID_STUDIO\jre 中有我的 jre,它对我有用。
Delete jre file in C:\Program Files\Android\Android Studio.删除C:\Program Files\Android\Android Studio中的jre文件。 Then create new jre folder and paste all contents from copy contents in C:\Program Files\Android\Android Studio\jbr.
然后创建新的jre文件夹并粘贴C:\Program Files\Android\Android Studio\jbr中复制内容中的所有内容。 Works like a charm.
奇迹般有效。
Make sure of your you install java 11 on your pc if You don't have installed ==> download it now from oracle.com/in/java/technologies/javase/jdk11-archive-downloads.html Make sure of your you install java 11 on your pc if You don't have installed ==> download it now from oracle.com/in/java/technologies/javase/jdk11-archive-downloads.html
==> add JAVA_HOME environment to your pc with the path of java C:\Program Files\Java\jdk-11.0.15 ==> 将 JAVA_HOME 环境添加到您的电脑,路径为 java C:\Program Files\Java\jdk-11.0.15
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.