【问题标题】:react-native not working on physical devicereact-native 在物理设备上不起作用
【发布时间】:2021-02-22 08:24:42
【问题描述】:

我是 react native 的新手,所以请帮助我开始。我只是使用这个命令创建了我的第一个 react-native 项目

npx react-native init AwesomeProject

我已经安装了android studio并在环境中添加了sdk的路径。在我的 android 中也使用了开发者选项。当我运行该命令时

npx react-native run-android

它给了我很多这样的错误

* What went wrong:
Could not determine the dependencies of task ':app:installDebug'.
> 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 'E:\react_native\AwesomeProject\android\local.properties'.

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

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

【问题讨论】:

    标签: react-native


    【解决方案1】:
    • 转到你的 react-native 项目的 android/ 目录
    • 使用此行创建一个名为 local.properties 的文件:

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

    USERNAME 是您的 macOS 用户名

    找到更多信息here

    【讨论】:

      猜你喜欢
      • 2016-12-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-07
      • 1970-01-01
      • 2018-02-24
      相关资源
      最近更新 更多