-2

I have installed react native and Android in my Linux mint. I have created a project

react-native init <appName>

after that i ran this code in terminal

react-native run-android

I am getting error

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> 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 '/var/www/html/react/megaMillion/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 0s
error Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
error Command failed: ./gradlew app:installDebug. Run CLI with --verbose flag for more details.

Can i know the problem. bcause i have tried a lot with this. Thank in advance.

Now getting this error.

info JS server already running.
info Building and installing the app on the device (cd android && ./gradlew app:installDebug)...
> Task :app:installDebug FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:installDebug'.
> com.android.builder.testing.api.DeviceException: No connected devices!

* 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

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.4.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 2s
26 actionable tasks: 1 executed, 25 up-to-date
error Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
error Command failed: ./gradlew app:installDebug. Run CLI with --verbose flag for more details.

Please help me to install this. Thanks in advance.

Ranjit
  • 1,684
  • 9
  • 29
  • 61
  • 1
    https://stackoverflow.com/questions/27620262/sdk-location-not-found-define-location-with-sdk-dir-in-the-local-properties-fil/27620622 – Tim Jun 17 '19 at 07:39
  • The solution is directly in the error message: "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 '/var/www/html/react/megaMillion/android/local.properties'." – Florian Cargoet Jun 17 '19 at 07:44
  • It is already defined. Still getting the error. – Ranjit Jun 17 '19 at 07:57

1 Answers1

0

You need to add ANDROID_HOME to your path, add the following to your .bashrc || .zshrc || .profile file

# change $HOME to the path where you installed android Sdk
export ANDROID_HOME=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/tools

Then run

$ source ~/.bashrc || .zshrc || .profile
Junius L
  • 15,881
  • 6
  • 52
  • 96