Followers

Visual Studio Code First React Native App unable to run - facing run-android issue

Visual Studio Code First React Native App unable to run - facing run-android issue


Trying to run the first React Native app and failing then don't worry here is the solution:


Error:  

* What went wrong:

Could not determine the dependencies of task ':app:installDebug'.

> 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 'PATH_OF_YOUR_APP/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 1s

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


Solution:


Step 1 :  

Either local.properties file is missing in your android folder of react native app or the sdk path is incorrect in the file 

(i) Make sure you have local.properties file in your android folder if not add local.properties file 

Create local.properties file under android folder in react native app if you don't find it there

(ii) Open Android Studio get the Android SDK Location from 

Android Studio -> Preferences -> Appearance & Behaviour -> System Settings -> Android SDK 

Here you can copy the path provided in the box next to Android SDK Location and add to your local.properties file as such 

sdk.dir = SDK PATH COPIED

(iii) Next from Visual Studio Terminal enter the command 

cd android 

and then 

./gradlew clean

(iv)  Enter the command below to enter the react native project created 

cd PATH_OF_YOUR_REACT_NATIVE_APP

and then run the app with the below command 

npx react-native run-android 


Step 2:



Open gradle-wrapper.properties from Android Project and change your distribution url as below and sync


distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip



If you are still facing issue then verify the steps from the below link 

npx react-native run-android Failing in macOS


If you are facing jettifier issue then resolve it from the below link 

Resolve Jettifier Issue


Stay tuned to my posts  and do share your valuable thoughts if any queries or you would like to share anything on this topic in the comment section and please do like and share my post if this was helpful.


Hope this helped you!!


Post a Comment

0 Comments