简体   繁体   English

在 React Native 上运行 Android Build 时出错

[英]Error While Running Android Build On React Native

I have installed all necessary SDK , Platform Tools .我已经安装了所有必要的 SDK、平台工具。 I've the emulator open and running, adb added in PATH.我已经打开并运行了模拟器,在 PATH 中添加了 adb。 Still this error isn't letting me through.这个错误仍然没有让我通过。

info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 967 file(s) to forward-jetify. Using 4 workers...
info JS server already running.
info Launching emulator...
/bin/sh: adb: command not found
info Installing the app...
error Failed to launch emulator. Reason: No emulators found as an output of `emulator -list-avds`.
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.2/userguide/command_line_interface.html#sec:command_line_warnings
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
 FAILURE: Build failed with an exception.flag for more details.


* 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 '/Users/manndave/IdeaProjects/MyFirstReactNative/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 3s

Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081```

Please run the following from terminal, inside the project folder请从终端运行以下命令,在项目文件夹内

export ANDROID_HOME=/Users/{yourusername}/Library/Android/sdk
export PATH=$ANDROID_HOME/platform-tools:$PATH
export PATH=$ANDROID_HOME/tools:$PATH

Then npm run android然后 npm 运行 android

In my case, I had running Metro Bundler from another project.就我而言,我从另一个项目运行 Metro Bundler。 Closing it is solved my issue.关闭它解决了我的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM