Instructions to run React Native project on Ubuntu with Expo, Android Studio
- 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
1 2 3 4 5 6 7 8 9 10 11 12 | apt-get update 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 source ~/.bashrc // check version of nvm nvm --version |
- Install Node and npm
1 2 3 4 5 6 7 8 9 10 | // install latest node nvm install node // set default node version for nvm nvm alias default node // check version of node and npm node -v npm -v |
2. Install Android Studio
- Install Java
1 2 | sudo apt install openjdk-8-jre openjdk-8-jdk |
- Install Android Studio
1 2 | sudo snap install android-studio |
After installation 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 Configure
Selection SDK Manager
.
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 Configure
Selection AVD Manager
.
Display 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 Next
.
Selection system image
for the device. If your selection has not been downloaded, select Download
corresponding to each row in the table system image
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 itExpo CLI
according to the command below.
1 2 | npm install --global expo-cli |
- Init & start project
1 2 3 4 5 6 7 8 | // init react-native project with name "my-app" expo init my-app cd my-app // start project expo start |
- After starting the project, you will see a browser to manage your project
expo
. SelectionRun on Android device/emulator
to connect to the virtual machine you just created.
Ending
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