Javascript npm运行android生成异常

Javascript npm运行android生成异常,javascript,node.js,reactjs,react-native,npm,Javascript,Node.js,Reactjs,React Native,Npm,我已经在我的ubuntu操作系统上安装了Node15,这是我第一天使用react,我遵循文档安装指南 这个错误发生了,请帮我解决 npm-g创建反应本机应用程序 然后创建react应用程序 当我使用npm Run android运行应用程序时 错误发生了 FAILURE: Build failed with an exception. * Where: Build file '/home/abubakar/Desktop/React/React Native proj/myApp/node_m

我已经在我的ubuntu操作系统上安装了Node15,这是我第一天使用react,我遵循文档安装指南 这个错误发生了,请帮我解决

npm-g创建反应本机应用程序
然后
创建react应用程序
当我使用npm Run android运行应用程序时 错误发生了

FAILURE: Build failed with an exception.

* Where:
Build file '/home/abubakar/Desktop/React/React Native proj/myApp/node_modules/react-native-reanimated/android/build.gradle' line: 89

* What went wrong:
A problem occurred configuring project ':react-native-reanimated'.
> 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 '/home/abubakar/Desktop/React/React Native proj/myApp/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 10s

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 app:installDebug -PreactNativeDevServerPort=8081

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ android: `react-native run-android`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @ android script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/abubakar/.npm/_logs/2021-04-07T00_51_03_506Z-debug.log

这是因为项目中缺少Android Studio主路径

为此,请转到您的\u项目\u目录/android

创建文件local.properties

在其中编写以下代码

dir=my case/root/ANDROID/sdk中您的ANDROID\u sdk\u主页的路径

您可以通过打开android studio并转到SDK管理器来获得此路径。

它会起作用的


谢谢。

您遇到了异常,即未找到SDK位置意味着您的Android\u主路径丢失。 您正在使用Ubuntu,所以只需访问位于文档下载部分附近的主页。进入主页后,只需按ctrl+h,您将看到大量文件,然后搜索.profile文件,最后添加以下行

export ANDROID_HOME=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools

请按照此答案设置ANDROID_SDK_根目录