React Native: How to solve SDK location not found

As I said before, when We find an errors in anywhere in programmings, the best solution for our problem is follow the message instructions and find where the something wrong located.

In this case, I found errors when running my last React Native project, and I got this erros:

Starting JS server...
Building and installing the app on the device (cd android && ./gradlew installDebug)...

> Configure project :app 
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html


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. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 0s
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

Now look at the *what went wrong part, focus at this segment,

* 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.

The errors tell us that SDK location not found, as you know that react native need SDK to run the Android project, and sometimes the SDK have different location according to instalation process.

Back to the errors, it said that wee need to create some file called local.properties and defined the sdk.dir to where we were installed the SDK.

So, I touch new file in andoird/ in project, called local.properties, and using nano I fill the file:

sdk.dir = /home/sutriman/Android/Sdk

sutriman is my folder, so you can custom it as you need. I install the SDK using Android Studio, so in Linux it by default installed in home folder, and auto-create new file called /Android/Sdk.

I think enough, hope it will be usefull for me and you are. Keep learning 🙂



0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments

0
Would love your thoughts, please comment.x
()
x