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)
- NodeJS and NPM
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.