当前位置: 首页 > 知识库问答 >
问题:

React本机错误:“无法从'9.0.1'确定java版本。”

萧展鹏
2023-03-14

我正在研究MacOS,刚从react-native开始。

开始的第一步之一是运行:react-native run-androidreact-native run-ios。但我得到了这个错误:

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时得到的结果:

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 --version
javac 9.0.1

有什么办法解决这个问题吗?

共有1个答案

羊禄
2023-03-14

PROJECT_PATH/android/gradle/wrapper/gradle-wrapper.properties文件中,将DistributionURL更新为以下内容:

distributionUrl=https\://services.gradle.org/distributions/gradle-5.0-all.zip

请参阅相关的gradle分发文档

 类似资料:
  • 问题内容: 尝试将项目上传到并出现错误: 我读到它是等级错误,已在较高版本中修复,我尝试将版本更改为,但出现另一个错误: Gradle同步失败:无此类属性:类:org.gradle.api.attributes.Usage FOR_RUNTIME有关更多详细信息,请参阅IDE日志(帮助|显示日志)(571毫秒) 摇篮属性: 建立gradle项目 问题答案: 您还应该删除Java JDK。只需运行以

  • 从命令python setup.py egg_info完成输出:运行egg_info创建pip egg info/psycopg2.egg-info写入pip egg info/psycopg2.egg-info/PKG-info将顶级名称写入pip egg info/psycopg2.egg-info/top_level.txt写入依赖项链接到pip egg info/psycopg2.egg-

  • 我遵循了React本机错误:“无法从'9.0.1'确定java版本。”并更改为 在project_path/android/gradle/wrapper/gradle-wrapper.properties中 但这并没有解决我的问题,它显示了一个新的错误,不能添加任务“wrapper”,因为具有该名称的任务已经存在。

  • 我使用VSCode作为我的IDE。(没有Android Studio)。当我执行颤振医生时,我得到错误“无法确定捆绑Java版本”。这会影响什么吗?如果会,我该如何修复它?(我已经尝试修复环境变量中的路径。)

  • 问题内容: 我发表以下评论: 只与日志见面: 我的gradle版本是5.1.1: 我不确定如何进行(我尝试了升级/降级,但到目前为止没有任何效果)。 更新:当我跑步时,我得到以下信息: 我的包含: 问题答案: 您的系统中有两个不同的Gradle应用程序。 该 系统范围内的摇篮 本申请通过援引。 在 gradle这个-包装 的gradle产出,包装是具体到每一个项目,只能调用该项目的目录中,使用命令