Overview
React Native is a mobile development javascript framework that was created by Facebook used to create cross-platform native apps. Unlike other frameworks like Ionic, when you build a react native app, you aren’t building a hybrid app, you’re actually building a native app as you would with Java or Swift. The other added benefit is that one codebase is reused for both Android and iOS platforms so this can reap huge benefits from a business standpoint. React Native Apps are written in javascript and the UI is built using the react javascript library.
This article will walk you through how to set up React Native on Linux and create a React Native project. (Android Guide)
What you’ll need
For Android testing
- A working Java Installation
- Android Sdk
- Android Debug Bridge(adb)
Requirement
- NodeJS and NPM
Installing requirements
Java and Android SDK
We’ll install Java and the Java Runtime Environment, then we’ll install Oracle Java 8 as it is a requirement of gradle when running the react native app.
- JDK and JRE
- Oracle JDK
- Android SDK and ADB
To download the SDK, I recommend downloading the Android Studio IDE which will download the SDK automatically and store it in your /home directory. You can also download the command line tools and use the included sdkmanager
to achieve the same results. In any case you’ll have to visit: the Android Studio download page and choose the desired option.
Next, download ADB because you’ll need it when debugging on a connected device.
NodeJS and NPM
To verify that node is installed correctly:
Install React Native
Similar to react, it’s possible to install React Native using the Create React Native App
npm package but we won’t be doing that because it requires Expo which in turn requires an active internet connection during development. Instead, we’ll be installing the React Native CLI which is more flexible in my opinion.
Next, let us create our first project.
The initial set up will take a while so you’ll need to exercise some patience. When the set up is complete, plugin your android device and make sure you’ve enable USB Debugging on it. To make sure your device is properly connected:
If everything looks good, change into your project directory and run the following command.
There are a few things that might go wrong. You might get an error prompting you to point to your android sdk path. In that case:
While still in your root project directory.
Then try running the app again. Another issue you might face is a connectivity issue to your device. In that case, try running:
Try running your app again. If it succeeds, then you can begin editing your app. If it fails, read the console error and try to find possible solutions online.
Cheers!