react-social-login

The easiest way to integrate Social Login in your React Apps ...Checkout NPM

Sunday, September 16, 2018

Fixing npm run android issues



fix NPM RUN ANDROID

This command could either delight you with your first react native app launching nicely on an emulator OR frustrate you. This article provides a fix for most common issues encountered while running this.

Remember: React-Native as on SEP 2018 needs JDK8 (It doesn't work on 9+)
This is a source for most of the issues.

Let's tackle all common issues one-by-one.

Error: JAVA_HOME isn't set

Common Issues

1. JAVA SDK not installed

Fix:
Install Java SDK if this is the case.

Q. How do I find if JAVA is installed or not?
= Open command prompt and run java -version
If you see JAVA isn't recognized OR JAVA jre 9.0 (or above), fix this first.

You may also have multiple JAVA versions installed.
If you're on windows, navigate to program files/Java folder and look for jdk 1.8.x (JAVA8) folder. If doesn't exist, download and install from here. (If you have JAVA 9, the folder would be jdk-9)

2. JAVA SDK is installed but JAVA_HOME variable not set

Fix:
open command prompt and execute SET JAVA_HOME = path_to_your_java8_bin_folder (see 1. above)

3. JAVA_HOME is set but includes /bin

You may have JAVA_HOME set. However, when you create a new project using creat-react-native-app it attempts to add bin to the current path. So, if you JAVA_HOME already has bin, it becomes bin/bin. Instead of correcting JAVA_HOME (as you don't know, what this would break), navigate to your project folder/android and open gradlew.bat in a notepad.
Find JAVA_HOME and remove bin from set JAVA_EXE=%JAVA_HOME%/bin/java.exe


Error: Could not find com.android.tools.build:gradle:3.0.x

Fix:
Open build.gradle add google() as a repository

Error: Error:Could not initialize class com.android.sdklib.repositoryv2.AndroidSdkHandler

Common Cause
Your JAVA is pointing to JAVA 9 or above.  Ideally, if you've been following this article, you'd have fixed this already. But incase you jumped here, Open Command Prompt and run JAVA - version to ensure thGo to properties of PC and select Environmental Variables options. Fix the path to point to JDK 8 instead of 9. Following screenshot shows it to be 9.. Fix the path to point to your Java8.
Close and Open Command Prompt again and continue npm run android



Warning: 'adb' is not recognized as an internal or external command

Open the command prompt and run adb. If you see command unrecognized error, you don't have adb. You might have it, but not in path. For this, add platform-tools folder to your environmental variables.
Q. Where is this folder?
Try to look into C:\Users\\AppData\Local\Android\Sdk. If it isn't there, install it from Android Studio ->Tools->SDK Manager-> SDK Tools TAB ->Check "Android SDK platform-tools" and install.



No comments :

Post a Comment

What are your thoughts on this post? Did you like it?