- Tram Ho
Hi, Eri Huynh hello everyone! Recently, I have started to learn more about React-native. And the first difficulty I encountered was how to be able to Run Project React-native directly on Ubuntu 20.04 to dev. After a while of researching, I chose the solution of using Expo and an Emulator created by Android Studio which I find very convenient. So today I will share with everyone the way I am using to dev with project React-native.
To be able to run
project React-native I need to follow these steps:
1. Install Node and npm
Many of you, after installing node, still cannot run the project because it is not compatible with the current Node version of the project. So here I might need an extra
nvm for version management for Node
- Install nvm
apt-get install build-essential libssl-dev
// install nvm
curl-o-https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
// reload bash
// check version of nvm
- Install Node and npm
// install latest node
nvm install node
// set default node version for nvm
nvm alias default node
// check version of node and npm
2. Install Android Studio
- Install Java
sudo apt install openjdk-8-jre openjdk-8-jdk
- Install Android Studio
sudo snap install android-studio
android-studio completed. Please open the app
android-studio up, the application will now ask you to install additional packages needed to complete the installation. You just need to install according to the application’s application direction.
- Install SDK for Android Studio
After you have finished the installation
adnroid-studio, below section
Next, select the appropriate SDK to run your project. If it’s your first time installing, you can choose your own.
- Create virtual machine on Android Studio
Same goes for settings
SDK, please come in
AVD Manager will appear, then select
Create Virtual Device... for the first case, there is no previously created virtual machine.
Select the device and screen size on which you want to create the virtual machine. Then choose
system image for the device. If your selection has not been downloaded, select
Download corresponding to each row in the table
Finally give the device a name, and select
Finish to complete the virtual machine creation.
After creating the virtual machine is complete at the interface
ADV Manager you will see a list of virtual machines that you have created. Now you can Press the . button
Play to run the virtual machine just created
3. Create and run projects with Expo
- I will init the react-native project with projecti
Expo CLI. If you don’t have it, install it
Expo CLIaccording to the command below.
npm install --global expo-cli
- Init & start project
// init react-native project with name "my-app"
expo init my-app
// start project
- After starting the project, you will see a browser to manage your project
Run on Android device/emulatorto connect to the virtual machine you just created.
Yup, enjoy the result. So I have completed the steps to run the project run
react-native. If you have any problems during the installation, please comment in the comment section. I and everyone will support you, wish you success.
Please support, follow and give me comments so that I can gradually improve. Eri Huynh Thank you everyone