React Native 错误:“无法从 '9.0.1' 确定 java 版本." [英] React Native error: "Could not determine java version from '9.0.1'."
问题描述
我在 MacOS 上工作,刚开始使用 react-native
.
I'm working on MacOS and just starting with react-native
.
开始的第一步是运行:react-native run-android
或 react-native run-ios
.但我收到此错误:
One of the first steps to get started is to run: react-native run-android
or react-native run-ios
. But I'm getting this error:
react-native run-android
结果:
Scanning folders for symlinks in /Users/ric/myprojs/albums/node_modules (6ms)
Starting JS server...
Building and installing the app on the device (cd android && ./gradlew installDebug)...
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine java version from '9.0.1'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/android-setup.html
这是我运行 java --version
时得到的:
This is what I get when I run java --version
:
java --version
结果:
java 9.0.1
Java(TM) SE Runtime Environment (build 9.0.1+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.1+11, mixed mode)
mbp:albums ric$ java --version
java 9.0.1
Java(TM) SE Runtime Environment (build 9.0.1+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.1+11, mixed mode)
编辑
我的 javac 版本:
Edit
My javac version:
javac --version
结果:
javac 9.0.1
知道如何解决这个问题吗?
Any idea on how to fix this?
推荐答案
在您的 PROJECT_PATH/android/gradle/wrapper/gradle-wrapper.properties
文件中,更新您的 distributionUrl
到以下内容:
In your PROJECT_PATH/android/gradle/wrapper/gradle-wrapper.properties
file, update your distributionUrl
to the following:
distributionUrl=https://services.gradle.org/distributions/gradle-5.0-all.zip
查看相关的 gradle 发行版文档
这篇关于React Native 错误:“无法从 '9.0.1' 确定 java 版本."的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!