- Follow the steps given here to install Node.js and NPM.
- Verify whether NPM is installed by typing
npm -v
in a terminal window.
npm install -g react-native-cli
-
Download and install Android Studio as explained here.
-
Run Android Studio and open the SDK Manager. Under the SDK Platforms tab, check Show Package Details, expand Android 6.0 (Marshmallow) and check the following:
- Google APIs
- Android SDK Platform 23
- Intel x86 Atom_64 System Image
- Google APIs Intel x86 Atom_64 System Image
-
Under the SDK Tools tab, check Show Package Details, expand Android SDK Build Tools and check 23.0.1.
-
Click Apply to install all the selected packages.
-
Open a terminal window and type
sudo gedit ~/.profile
-
Add the following lines to the end of the file:
export ANDROID_HOME=${HOME}/Android/Sdk export PATH=${PATH}:${ANDROID_HOME}/tools export PATH=${PATH}:${ANDROID_HOME}/platform-tools
-
Type
source ~/.profile
in your terminal to load the config into your current shell. -
In Android Studio, open AVD Manager and click Create Virtual Device
-
Follow the setup wizard and give your device an appropriate name (you will need this name everytime you start the emulator through the command line, so make it short and simple). Click on Finish to create the Virtual Device.
-
If you set the Emulated Performance setting to Software, you will be able to run the emulator, but the performance will be very sluggish. Hence it is recommended to configure VM hardware acceleration.
- Install cpu-checker:
sudo apt-get install cpu-checker
- Check for KVM compatibility:
kvm-ok
If the output is says:
it means that your computer can be configured for VM acceleration.INFO: /dev/kvm exists KVM acceleration can be used
- Follow the steps given in this Ubuntu documentation in order to configure KVM.
- Install lib64stdc++6 and mesa-demos:
apt-get install lib64stdc++6:i386 mesa-utils
- Rename libstdc++.so.6 to libstdc++.so.6.bak:
cd ~/Android/Sdk/emulator/lib64/libstdc++` `mv libstdc++.so.6 libstdc++.so.6.bak
- Start the emulator:
replace foo with the name of your device. This should start your Android Emulator in VM accelerated mode.cd ~/Android/Sdk/tools ./emulator @foo
- Create a new React Native project:
react-native init HelloWorld
- Navigate to your project directory and type:
npm start
- In another terminal window, navigate to the project directory and type:
react-native run-android
I think it's better to work with real Android device rather than virtual machine.
http://www.techomoro.com/how-to-install-and-setup-react-native-on-ubuntu-17-10/