当我尝试运行 react-native run-android 命令时出错 [英] Error when I try to run react-native run-android command

查看:85
本文介绍了当我尝试运行 react-native run-android 命令时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

C:\Users\hp\Desktop\Reactprojects\Makerobos>react-native run-androidinfo 运行 jetifier 将库迁移到 AndroidX.您可以使用--no-jetifier"标志禁用它.Jetifier 找到了 855 个要转发 Jetify 的文件.使用 4 个工人...info JS 服务器已经在运行.信息正在安装应用程序...

C:\Users\hp\Desktop\Reactprojects\Makerobos>react-native run-android info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag. Jetifier found 855 file(s) to forward-jetify. Using 4 workers... info JS server already running. info Installing the app...

FAILURE:构建失败,出现异常.

FAILURE: Build failed with an exception.

  • 出了什么问题:配置项目:app"时出现问题.

  • What went wrong: A problem occurred configuring project ':app'.

未找到 SDK 位置.使用 ANDROID_SDK_ROOT 环境变量或通过在项目的本地属性文件中的C:\Users\hp\Desktop\Reactprojects\Makerobos\android\local.properties"中设置 sdk.dir 路径来定义位置.

SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project's local properties file at 'C:\Users\hp\Desktop\Reactprojects\Makerobos\android\local.properties'.

  • 试试:使用 --stacktrace 选项运行以获取堆栈跟踪.使用 --info 或 --debug 选项运行以获得更多日志输出.使用 --scan 运行以获得完整的见解.

  • 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.

    https://help.gradle.org

    在 5 秒内构建失败

    错误无法安装应用程序.确保您已设置 Android 开发环境:https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment.使用 --verbose 标志运行 CLI 以获取更多详细信息.错误:命令失败:gradlew.bat app:installDebug -PreactNativeDevServerPort=8081

    error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081

    FAILURE:构建失败,出现异常.

    FAILURE: Build failed with an exception.

    • 出了什么问题:配置项目:app"时出现问题.

    • What went wrong: A problem occurred configuring project ':app'.

    未找到 SDK 位置.使用 ANDROID_SDK_ROOT 环境变量或通过在项目的本地属性文件中的C:\Users\hp\Desktop\Reactprojects\Makerobos\android\local.properties"中设置 sdk.dir 路径来定义位置.

    SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project's local properties file at 'C:\Users\hp\Desktop\Reactprojects\Makerobos\android\local.properties'.

  • 试试:使用 --stacktrace 选项运行以获取堆栈跟踪.使用 --info 或 --debug 选项运行以获得更多日志输出.使用 --scan 运行以获得完整的见解.

  • 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.

    https://help.gradle.org

    在 5 秒内构建失败

    at checkExecSyncError (child_process.js:621:11)
    at execFileSync (child_process.js:639:15)
    at runOnAllDevices (C:\Users\hp\Desktop\Reactprojects\Makerobos\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:74:39)
    at buildAndRun (C:\Users\hp\Desktop\Reactprojects\Makerobos\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\index.js:158:41)
    at C:\Users\hp\Desktop\Reactprojects\Makerobos\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\index.js:125:12
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async Command.handleAction (C:\Users\hp\Desktop\Reactprojects\Makerobos\node_modules\react-native\node_modules\@react-native-community\cli\build\cliEntry.js:160:7)
    

    推荐答案

    您的 SDK 路径不正确,需要在以下文件中添加正确的路径:萨项目 >安卓 >local.properties

    Your SDK path is not correct you need to add a correct path in the below file: sa project > android > local.properties

    添加如下示例的路径:

    sdk.dir = /Users/admin/Library/Android/sdk
    

    添加后使用以下命令:

    1. cd android/
    2. ./gradlew clean
    3. cd ..
    4. Command: react-native bundle --platform android --dev false --entry-file indexcsasa.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
    csacs
    5. react-native run-android
    

    这篇关于当我尝试运行 react-native run-android 命令时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    相关文章
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆