Skip to main content

React Native on Android

Installing Dev Environment

On ubuntu you can install the android SDK with apt-get install android-sdk .

You'll need a target device to test your app against. You can plug it in and use adb to do the hard work. Make sure to install the Expo App on your target device - this will serve as a host on the device that allows it to run your new app in development and do hot-reloading of your code.

Creating a Project

Using npx create a new project with the tooling provided by React Native like so:

npx create-expo-app AwesomeProject
cd AwesomeProject
npm start # you can also use: npx expo start

Running the Project

Start the app with npm run android you might get error messages about not knowing where android home is. On ubuntu android home installed from deb packages is normally at /usr/lib/android-sdk   (source) so just run:

export ANDROID_HOME=/usr/lib/android-sdk before you try to launch the app.


Persisting Data

React Native is pretty modular so you need to use libraries to do most things. Use a storage library to store data. This MMKV storage library appears to be pretty efficient and allows you to store state across multiple databases very easily and quickly.

 

Using

the Camera

The expo-camera library seems to be a nice way to do cross-device camera stuff. I got it working very quickly.