Sunday, 7 January 2018

Setup react-native in Ubuntu 14.04

https://facebook.github.io/react-native/docs/getting-started.html

1) Install build tools
sudo apt-get install -y build-essential

2) Install react-native cli
npm install -g react-native-cli

3)Install android studio - From: https://developer.android.com/studio/install.html

download android studio
go to path to bin
./studio.sh

3B) setup android stdio
Choose a "Custom" setup when prompted to select an installation type. Make sure the boxes next to all of the following are checked:

Android SDK
Android SDK Platform
Android Virtual Device
Then, click "Next" to install all of these components.

If the checkboxes are grayed out, you will have a chance to install these components later on.

3c) Install required JDK
download the sdk for android 6.0 marshmallo

The SDK Manager can also be found within the settings-> Android Studio "Preferences" dialog, under Appearance & Behavior → System Settings → Android SDK.

make sure the following items are all checked:

Google APIs
Android SDK Platform 23
Intel x86 Atom_64 System Image
Google APIs Intel x86 Atom_64 System Image

Next, select the "SDK Tools" tab and check the box next to "Show Package Details" here as well. Look for and expand the "Android SDK Build-Tools" entry, then make sure that 23.0.1 is selected.

Finally, click "Apply" to download and install the Android SDK and related build tools.


4) . Configure the ANDROID_HOME environment variable
The React Native tools require some environment variables to be set up in order to build apps with native code.

Add the following lines to your $HOME/.bash_profile config file:

export ANDROID_HOME=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools

<But in my case, path was this>
/opt/android-sdk-linux
export ANDROID_HOME=/opt/android-sdk-linux
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools

Running the app on device


1) Enable Debugging over USB
Settings → About phone

2A) sudo apt-get install android-tools-adb

2B) Enter this command: lsusb, this should output something like this:
Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 22b8:2e76 Motorola PCS
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

These lines represent the USB devices currently connected to your machine.

You want the line that represents your phone. If you're in doubt, try unplugging your phone and running the command again:


2C) echo SUBSYSTEM=="usb", ATTR{idVendor}=="22b8", MODE="0666", GROUP="plugdev" | sudo tee /etc/udev/rules.d/51-android-usb.rules
-Make sure that you replace 22b8 with the identifier you get in the above command.
echo SUBSYSTEM=="usb", ATTR{idVendor}=="2717", MODE="0666", GROUP="plugdev" | sudo tee /etc/udev/rules.d/51-android-usb.rules
2717

3) react-native run-android

4) Add the hostname in device
Dev settings -> Debug server host and port for device
Enter the computer's ip address and port.
192.168.0.1:8081

5) react-native start

6) Clear the app from RAM and re-open

7) Here goes your app, :)


Create unsignesh apk
http://bitstopixels.blogspot.in/2017/05/installing-react-native-unsigned-debug.html



*********

ISSUES  I GOT


ISSUE1 running react-native run-android
Exception in thread "main" javax.net.ssl.SSLException: java.security.ProviderException: java.security.InvalidKeyException: EC parameters error


SOL1: Install JDK 8 or above.
https://askubuntu.com/questions/464755/how-to-install-openjdk-8-on-14-04-lts
Original Message
If you really want to use OpenJDK, you have to compile from source. There is not still any PPA for OpenJDK.

It has been requested at https://bugs.launchpad.net/ubuntu/+bug/1297065

I recommend you to use Webup8 Oracle Java8 Installer

sudo add-apt-repository ppa:webupd8team/java -y
sudo apt-get update
sudo apt-get install oracle-java8-installer
To automatically set up the Java 8 environment variables

sudo apt-get install oracle-java8-set-default
Check it

java -version
So you have to wait to use OpenJDK8


SOL2:
:-JAVA_HOME path variable was not installed.
https://github.com/facebook/react-native/issues/14091
export JAVA_HOME="/usr/lib/jvm/java-7-openjdk-amd64"
export PATH=$JAVA_HOME/bin:$PATH




Issue2:- creating react-native run-android from git project, that is already created...
ERROR: Android project not found. Maybe run react-native android first?
SOLUTION: run: react-native upgrade
- https://stackoverflow.com/questions/43723958/react-native-android-project-not-found-maybe-run-react-native-android-first

Issue3:  ERROR  watch /home/shubham/shubham/shubham/projects/react-native/awesomeProject/node_modules/lodash._reevaluate ENOSPC
SOLUTION1: install watchman

Issue4:-
All these above steps work well but when I ran with react-native-camera, the app build used to hand when I ran "react-native run-android" like this:
JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug)...
File /home/shubham/.android/repositories.cfg could not be loaded.
Checking the license for package Android SDK Platform 25 in /opt/android-sdk-linux/licenses
License for package Android SDK Platform 25 accepted.
Preparing "Install Android SDK Platform 25".
> Configuring > 3/3 projects
Solution1:
Could be due to build-tools verion 25, installing sdk-build tools [25.0.2, 27.0.2,23.0.1], Android sdk platform-tools, android sdk tools solved this problem.
If not, please try installing all sdk-build tools for version 25.x.x to 27.x.x

ISSUE5: Watchman crawl failed. Retrying once with node crawler.
SOLUTION1:
Try running these commands
echo 999999 | sudo tee -a /proc/sys/fs/inotify/max_user_watches
echo 999999 | sudo tee -a /proc/sys/fs/inotify/max_queued_events
echo 999999 | sudo tee -a /proc/sys/fs/inotify/max_user_instances
SOLUTION2:
If solution1 does not work, try shutdown webpack by this command:
watchman shutdown-server

****************************************************************************************************************
****************************************************************************************************************

No comments:

Post a Comment