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

React原生,为什么react-native run-android不工作?

颛孙晗昱
2023-03-14

我试图运行命令react-native run-android,但它抛出了一个错误。我在遵循文档我遵循了每一步,但它不起作用,我认为这不是选择路径,而是它设置如文档所示。谁能告诉我出什么事了吗?

info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
(node:12536) 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 967 file(s) to forward-jetify. Using 4 workers...
info Starting JS server...
'C:\Users\Danger' is not recognized as an internal or external command,
operable program or batch file.
info Launching emulator...
'C:\Users\Danger' is not recognized as an internal or external command,
operable program or batch file.
'C:\Users\Danger' is not recognized as an internal or external command,
operable program or batch file.
'C:\Users\Danger' is not recognized as an internal or external command,
operable program or batch file.
'C:\Users\Danger' is not recognized as an internal or external command,
operable program or batch file.
'C:\Users\Danger' is not recognized as an internal or external command,
operable program or batch file.
'C:\Users\Danger' is not recognized as an internal or external command,
operable program or batch file.
'C:\Users\Danger' is not recognized as an internal or external command,
operable program or batch file.
'C:\Users\Danger' is not recognized as an internal or external command,
operable program or batch file.
'C:\Users\Danger' is not recognized as an internal or external command,
operable program or batch file.
'C:\Users\Danger' is not recognized as an internal or external command,
operable program or batch file.
'C:\Users\Danger' is not recognized as an internal or external command,
operable program or batch file.
'C:\Users\Danger' is not recognized as an internal or external command,
operable program or batch file.
'C:\Users\Danger' is not recognized as an internal or external command,
operable program or batch file.
'C:\Users\Danger' is not recognized as an internal or external command,
operable program or batch file.
'C:\Users\Danger' is not recognized as an internal or external command,
operable program or batch file.
'C:\Users\Danger' is not recognized as an internal or external command,
operable program or batch file.
'C:\Users\Danger' is not recognized as an internal or external command,
operable program or batch file.
error Failed to launch emulator. Reason: Could not start emulator within 30 seconds..
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
info Installing the app...

FAILURE: Build failed with an exception.

* What went wrong:
Could not initialize class org.codehaus.groovy.runtime.InvokerHelper

* 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 17s

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

共有1个答案

曹建明
2023-03-14

做这些。

  1. 确保JDK版本为8或更高。
  2. 确保android路径设置正确。
  3. 删除Android/build和Android/app/build文件夹。

编辑:如果JDK版本为14,而gradle版本小于6.3,则必须将JDK降级到11,或者将gradle升级到6.3以上

 类似资料:
  • 我克隆了存储库:https://github.com/facebook/react-native,并尝试在Android仿真器上运行UIExplorer示例。 我在Android模拟器上收到了这个错误消息:

  • 每次我重新打开项目和模拟器时,我都必须在命令提示符中运行和吗? 谢谢。

  • 遇到这个问题的人都无法解决配置':react-native-fast-image:classpath'的所有工件,并且找不到com.android.tools.build:gradle:3.6.3?我试着打开项目结构,看到gradle插件工具是3.6.3,而gradle版本是5.4.6,但我不知道现在发生了什么 build.gradle文件:

  • 我目前在react Native上有点挣扎。我想拥有的是一个基于react原生的库项目,然后我可以包括在我的一些应用程序。 通过启动dev-server没有任何问题,但是只要我启动Android应用程序,就会得到folowwing logcat输出: 请注意,我执行了操作,但仍然显示错误。 稍后,我想从Android库项目中创建一个aar,并通过Maven访问它。

  • 我在编译时没有错误,实际上这是从哪里冒出来的。其他人有这个错误吗? 任务:react-native-webview:compiledebugjavawithjavac注意:/user_data/projects/react-native/populi/node_modules/react-native-webview/android/src/main/java/com/reactnativeCom

  • 我已经完成了所有的设置为Android和iOS反应原生从下面的链接在我的mac mashine。 项目已成功创建。但当我试图在终端中使用以下命令运行Android项目时: 我得到了下面的错误 > 问题:配置项目“:app”时出现问题。 SDK目录“/usr/local/opt/android SDK”不存在。 尝试:使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debu