0

I have node 15 installed on my ubuntu OS this is my first day with react I follw the documentation Installation Guide https://reactnative.dev/docs/getting-started

and this error occurred please help me out

npm -g create-react-native-app

then

create-react-app

When I run the app using the npm run android, I get this error:

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

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

2 Answers2

0

This is because your Android Studio Home path is missing from your project.

For this go to your_project_directory/android

create a file local.properties

write the following code in it.

sdk.dir=path to your ANDROID_SDK_HOME in my case /root/Android/Sdk

you can get this path by opening the android studio and go to the SDK Manager. ANDROID_SDK_HOME_ATH

It will work.

Thank you.

0

You got Exception i.e SDK location not found means your Android_Home path is missing. Your are using Ubuntu so just go to the Home which is present near Documents, Download section. After entered in Home just press ctrl+h, you will see lots of files then search .profile file and add following lines at last.

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