React Native run - Android 产生奇怪的错误

问题描述

我想询问以下错误。所以我一年前一直在开发一个小的 BLE 应用程序并成功地实现了它。我没有将它推送到 Google Play 商店,而是通过 USB 以某种方式将其安装在 Android 上。

但是,现在我需要重新启动并运行它,但我面临着大量错误

PS C:\Users\stefanec\Desktop\SOC\i_garden\i_garden\iGard> npx react-native run-android 
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 1302 file(s) to forward-jetify. Using 8 workers...
info Starting JS server...
info Installing the app...

> Configure project :app

Installing unimodules:
 unimodules-core@5.0.0 from C:\Users\stefanec\Desktop\SOC\i_garden\i_garden\iGard\node_modules\@unimodules\core
 unimodules-react-native-adapter@5.0.0 from C:\Users\stefanec\Desktop\SOC\i_garden\i_garden\iGard\node_modules\@unimodules\react-native-adapter
 expo-app-loader-provider@8.0.0 from C:\Users\stefanec\Desktop\SOC\i_garden\i_garden\iGard\node_modules\expo-app-loader-provider
 expo-constants@8.0.0 from C:\Users\stefanec\Desktop\SOC\i_garden\i_garden\iGard\node_modules\expo-constants
 expo-error-recovery@1.0.0 from C:\Users\stefanec\Desktop\SOC\i_garden\i_garden\iGard\node_modules\expo-error-recovery
 expo-file-system@8.0.0 from C:\Users\stefanec\Desktop\SOC\i_garden\i_garden\iGard\node_modules\expo-file-system
 expo-font@8.0.0 from C:\Users\stefanec\Desktop\SOC\i_garden\i_garden\iGard\node_modules\expo-font
 expo-keep-awake@8.0.0 from C:\Users\stefanec\Desktop\SOC\i_garden\i_garden\iGard\node_modules\expo-keep-awake
 expo-linear-gradient@8.0.0 from C:\Users\stefanec\Desktop\SOC\i_garden\i_garden\iGard\node_modules\expo-linear-gradient
 expo-location@8.0.0 from C:\Users\stefanec\Desktop\SOC\i_garden\i_garden\iGard\node_modules\expo-location
 expo-permissions@8.0.0 from C:\Users\stefanec\Desktop\SOC\i_garden\i_garden\iGard\node_modules\expo-permissions
 expo-sqlite@8.0.0 from C:\Users\stefanec\Desktop\SOC\i_garden\i_garden\iGard\node_modules\expo-sqlite
 expo-web-browser@8.0.0 from C:\Users\stefanec\Desktop\SOC\i_garden\i_garden\iGard\node_modules\expo-web-browser
 unimodules-barcode-scanner-interface@5.0.0 from C:\Users\stefanec\Desktop\SOC\i_garden\i_garden\iGard\node_modules\unimodules-barcode-scanner-interface
 unimodules-camera-interface@5.0.0 from C:\Users\stefanec\Desktop\SOC\i_garden\i_garden\iGard\node_modules\unimodules-camera-interface
 unimodules-constants-interface@5.0.0 from C:\Users\stefanec\Desktop\SOC\i_garden\i_garden\iGard\node_modules\unimodules-constants-interface
 unimodules-face-detector-interface@5.0.0 from C:\Users\stefanec\Desktop\SOC\i_garden\i_garden\iGard\node_modules\unimodules-face-detector-interface
 unimodules-file-system-interface@5.0.0 from C:\Users\stefanec\Desktop\SOC\i_garden\i_garden\iGard\node_modules\unimodules-file-system-interface
 unimodules-font-interface@5.0.0 from C:\Users\stefanec\Desktop\SOC\i_garden\i_garden\iGard\node_modules\unimodules-font-interface
 unimodules-image-loader-interface@5.0.0 from C:\Users\stefanec\Desktop\SOC\i_garden\i_garden\iGard\node_modules\unimodules-image-loader-interface
 unimodules-permissions-interface@5.0.0 from C:\Users\stefanec\Desktop\SOC\i_garden\i_garden\iGard\node_modules\unimodules-permissions-interface
 unimodules-sensors-interface@5.0.0 from C:\Users\stefanec\Desktop\SOC\i_garden\i_garden\iGard\node_modules\unimodules-sensors-interface
 unimodules-task-manager-interface@5.0.0 from C:\Users\stefanec\Desktop\SOC\i_garden\i_garden\iGard\node_modules\unimodules-task-manager-interface

The Kotlin Gradle plugin was loaded multiple times in different subprojects,which is not supported and may break the build.
This might happen in subprojects that apply the Kotlin plugins with the Gradle 'plugins { ... }' DSL if they specify explicit versions,even if the versions are equal.
Please add the Kotlin plugin to the common parent project or the root project,then remove the versions in the subprojects.
If the parent project does not need the plugin,add 'apply false' to the plugin line.
See: https://docs.gradle.org/current/userguide/plugins.html#sec:subprojects_plugins_dsl
The Kotlin plugin was loaded in the following projects: ':expo-error-recovery',':expo-permissions'

> Task :@react-native-community_async-storage:compileDebugJavaWithJavac Failed

Deprecated Gradle features were used in this build,making it incompatible with Gradle 5.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/4.10.2/userguide/command_line_interface.html#sec:command_line_warnings
10 actionable tasks: 1 executed,9 up-to-date

FAILURE: Build Failed with an exception.

* What went wrong:
Execution Failed for task ':@react-native-community_async-storage:compileDebugJavaWithJavac'.
> Could not find tools.jar. Please check that C:\Program Files (x86)\Java\jre1.8.0_251 contains a valid JDK installation.

* 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

BUILD Failed in 31s

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:\Users\stefanec\Desktop\SOC\i_garden\i_garden\iGard>

解决方法

您似乎没有安装 JDK。

如果您使用的是 Mac,请使用下面的命令通过 brew 安装它,或者按照文档了解如何在您的特定机器上安装

brew install --cask adoptopenjdk/openjdk/adoptopenjdk8

按照此 guide 在 Windows 上安装

查看文档 https://reactnative.dev/docs/_getting-started-macos-android#installing-dependencies

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...