1

So I'm getting this error

~/projects/personal-projects/react/myapp ⌚ 18:12:24
$ react-native run-android --variant=release  
Scanning folders for symlinks in /Users/user/projects/personal-projects/react/myapp/node_modules (22ms)
JS server already running.
Building and installing the app on the device (cd android && ./gradlew installRelease)...

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 14.706 secs
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

I already have my android sdk installed and I also have java installed.

this is what is in my .bach_profile

export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools
export JAVA_HOME=$Home/Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home

I've tried adding a local.properties file and added sdk.dir pointing to my Android/sdk folder. But still this error persists. How do I fix this?

5
  • Add environment variable in ANDROID_HOME and JAVA_HOME pointing to jdk and android sdk Commented Mar 16, 2018 at 10:20
  • Where do I locate the jdk @ParasWatts Commented Mar 16, 2018 at 10:21
  • 1
    Search in /usr/lib/jvm/ Commented Mar 16, 2018 at 10:25
  • I've added Java_home but it's still giving me the error @ParasWatts Commented Mar 16, 2018 at 10:29
  • 1
    askubuntu.com/questions/175514/how-to-set-java-home-for-java check this thread for setting java_home Commented Mar 16, 2018 at 10:30

3 Answers 3

1

Please make file local.properties in folder android then add the following line on file

sdk.dir=/Users/apple/Library/Android/sdk(Please add your sdk path here)
Sign up to request clarification or add additional context in comments.

Comments

1

You need to add ANDROID_HOME, JAVA_HOME variables in environmental variables and tools and platform-tools in path of system to run android apk.

Setting ANDROID_HOME variable in environmental variables.

Setting JAVA_HOME variable in environmental variables.

Comments

0

So the solution to my problem was:

1) add my ANDROID_HOME and JAVA_HOME paths in my .bash_profile

  • Solution by @rana_sadam

2) Create local.properties and add sdk.dir=<PATH TO ANDROID SDK> inside the android folder.

  • Solution by @nisarg Thakkar

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.