0

I'm new in React-Native. I tried several solution in some forums but didn't help. Bellow the errors .

   Microsoft Windows [Version 10.0.17134.407]
(c) 2018 Microsoft Corporation. All rights reserved.

C:\xampp\htdocs\Hands-on React-Native\TripPlane>react-native run-android
Starting JS server...
Building and installing the app on the device (cd android && gradlew.bat installDebug)...

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 19s
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
halfer
  • 19,824
  • 17
  • 99
  • 186
Jose Pinto
  • 93
  • 1
  • 10

1 Answers1

0

You need to setup ReactNative properly.

I have consider that android studio is already installed and emulator or android device is already attached

Follow below steps!

1] Install JDK from official site

2] Install NodeJs from official site

3] Install Python 2 form official site

4] Install ReactNative CLI , open CMD [ right click and run as administrator ]

  • Type C:\WINDOWS\system32>node -v // to get node version

  • Type C:\WINDOWS\system32>npm install -g react-native-cli // to install RN CLI

5] Create workspace of your RN projects - D:\ReactNative>react-native init projectname //it will generate project inside mentioned path.

6] setup environment variable

  • set up new variable under user variable (if not exist) JAVA_HOME with the value C:\Program Files\Java\jdk-10.0.2 (your JDK path)

  • set up new variable under user variable (if not exist) Path with the value C:\Users\Admin\AppData\Local\Android\sdk\platform-tools //your sdk platform tools path

7] run your project using following command inside CMD D:\ReactNative>react-native run android

Radhey
  • 2,139
  • 2
  • 24
  • 42
  • Sorry! But the step 6 I don't understand. I cannot find the User variable to add this path that you wrote. In witch file should I find or create a new file ? – Jose Pinto Dec 06 '18 at 08:56
  • inside search box of windows start up menu search `environment variable`. click on `environment variable` button. then one popup will come with 2 options.user variable and system variable. you need to edit inside user variable. – Radhey Dec 06 '18 at 09:35
  • Radhey thanks for your support. But I did all the step that you mentioned up and did not help. Take look the error bellow – Jose Pinto Dec 07 '18 at 07:52
  • FAILURE: Build failed with an exception. * What went wrong: Could not determine java version from '11.0.1'. * 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 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 – Jose Pinto Dec 07 '18 at 07:54