Quickly Building a React Native App
Setting up your first app doesn’t need to be too daunting. A step by step guide.
This article will show you how to get your first app up and running super quick. For this I’m assuming your development environment is macOS and your target iOS is
A purist method is adopted where we build the native app as would clasically be used to deploy in Google Play or Apple Store. There are alternative methods which use Expo. The relative differences shown below:
If you use the Expo approach the you need to run an Expo server locally and install a Expo client on your mobile (or run a mobile simulator). All changes can be done on the Expo server and the App is updated in seconds. Over the air (OTA).
If we use the React Native approach we run everything in the mobile device (or simulator). Push the code to Google Play and Apple Store as per usual. the updates take much longer to be applied as the who app needs to be redeployed. However, it’s a more of a purist approach.
Here we’re going to use React Native CLI, this is the process to follow when you want the freedom to be able to integrate into other parts of the application.
You will need Node, Watchman, the React Native command line interface, a JDK, and Android Studio.
Node & Watchman
brew install node
brew install watchman
If you have already installed Node on your system, make sure it is Node 12 or newer.
Watchman is a tool by Facebook for watching changes in the filesystem. It is highly recommended you install it for better performance.
Java Development Kit
Install a version of java.
brew install --cask adoptopenjdk/openjdk/adoptopenjdk8
If you have already installed JDK on your system, make sure it is JDK 8 or newer.
Ensure you install Android Studio with these components.
Android SDK Platform
Android Virtual Device
Android Studio installs the latest Android SDK by default. Building a React Native app with native code, however, requires the
Android 10 (Q) SDK in particular. Additional Android SDKs can be installed through the SDK Manager in Android Studio.
To do that, open Android Studio, click on “Configure” button and select “SDK Manager”.
Select the “SDK Platforms” tab from within the SDK Manager, then check the box next to “Show Package Details” in the bottom right corner. Look for and expand the
Android 10 (Q) entry, then make sure the following items are checked:
Android SDK Platform 29
Intel x86 Atom_64 System Imageor
Google APIs Intel x86 Atom 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
29.0.2 is selected and check the "Android SDK Command-line Tools (latest)".
Finally, click “Apply” to download and install the Android SDK and related build tools.
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/.bashrc (if you are using
~/.zshrc) config file:
export ANDROID_HOME=$HOME/Library/Android/sdkexport PATH=$PATH:$ANDROID_HOME/emulatorexport PATH=$PATH:$ANDROID_HOME/toolsexport PATH=$PATH:$ANDROID_HOME/tools/binexport PATH=$PATH:$ANDROID_HOME/platform-tools
.bash_profileis specific to
bash. If you're using another shell, you will need to edit the appropriate shell-specific config file.
source $HOME/.bash_profile for
source $HOME/.zprofile to load the config into your current shell. Verify that ANDROID_HOME has been set by running
echo $ANDROID_HOME and the appropriate directories have been added to your path by running
Please make sure you use the correct Android SDK path. You can find the actual location of the SDK in the Android Studio “Preferences” dialog, under Appearance & Behavior → System Settings → Android SDK.
It’s really important too get your JAVA HOME path correct. Begin by first checking what you have setup:
echo $JAVA_HOME#if JAVA HOME is empty and does not have a line like the following corresponding to your installed version then you need to set this
/Library/Java/JavaVirtualMachines/jdk1.8.0_66.jdk/Contents/Home#to check JAVA installed
java -version#check your shell running
#If you get this /bin/zsh then you're running zsh shellvi ~/.zshrc
# add the following anywhere
npx react-native <command>, the current stable version of the CLI will be downloaded and executed at the time the command is run.
Launch a New Mobile App
React Native has a built-in command line interface, which you can use to generate a new project. You can access it without installing anything globally using
npx, which ships with Node.js. Let's create a new React Native project called "BadAssProject":
npx react-native init BadAssProject
Get a Virtual Device Ready
If you use Android Studio to open
./BadAssProject/android, you can see the list of available Android Virtual Devices (AVDs) by opening the "AVD Manager" from within Android Studio. Look for an icon that looks like this:
If you have recently installed Android Studio, you will likely need to create a new AVD. Select “Create Virtual Device…”, then pick any Phone from the list and click “Next”, then select the Q API Level 29 image.
Click “Next” then “Finish” to create your AVD. At this point you should be able to click on the green triangle button next to your AVD to launch it, then proceed to the next step.
Start the App
Let Metro Bundler run in its own terminal. Open a new terminal inside your React Native project folder. Run the following:
npx react-native run-android
npx react-native run-android is one way to run your app - you can also run it directly from within Android Studio.
The BadAss project can be modified bu just editing App.js in the project folder.
You can now think about how to integrate your app so its updated from an API and adding more features.
Why Build an App?
If this is your first App and you want to go further down a startup route then have a think about what is the problem or pain point you want to fix? What value does your App provide? And then and only then think about your App and the solution you will build. When you do build the solution get the user stories correct, then wireframe and then code. I hope to write a further post soon detailing how to setup a simple API to provide content to the App. If you have questions please feel free to reach out. I build stuff at elbornlab.com.
Creating a React Native App With a Ruby On Rails Backend (Part 1 of 3)
Note: I will be using ruby 2.4.2 and Rails 22.214.171.124 for this project. You can check your Ruby versions by running ruby…
How I built my first React Native app for my first freelance client
by Charlie Jeppsson How I built my first React Native app for my first freelance clienthttps://www.pexels.com/@nietjuhI…
Learn the Basics · React Native
React Native is like React, but it uses native components instead of web components as building blocks. So to…