npm install -g react-native-cli
npm install
react-native link
- start your emulator or connect device over USB
- start your emulator
cd ~/Library/Android/sdk/tools
emulator -list-avds
emulator @[DEVICE_NAME]
- connect to device (TODO: write device debugging section)
- start your emulator
npm start
react-native run-android
react-native log-android
(optional)
The general development cycle is:
- Make some changes
- Reload in the app (on emulator or device).
Tip: You can enable "Live Reload" and "Hot Reloading" in the RN app menu. Both are ways to make it so you don't have to manually reload every time. They work differently both have their own pro's/con's - When you make some changes and they don't seem to be showing up:
- Run
react-native run-android
again. - If that doesn't work,
control-c
the JS server and runnpm start
again, followed by a manual reload in the app
- Run
- ⌘M for RN Menu in emulator
- Double-tap the r key on your keyboard to reload
Shake to get RN Menu
In the RN menu, choose "Start Remote JS Debugging". A Chrome window will open. Open the console and go at it!
After generating new Java code, run node makeStyleKit.js -j /com/optek/guitartunes/GuitarTunesStyleKit.java -s src/components/StyleKit/styleKitComponents.js
- Install
react-native-git-upgrade
globally with NPM - run
react-native-git-upgrade
- Update Android Studio every once in a while by opening. It will prompt you for updates when opening.2
- In Android Studio, go to the menu
- Tools -> Android -> SDK Manager
- Under Android SDK, choose the SDK Tools tabs and find updates
- To update to the latest React Native (can be dangerous), run
react-native-git-upgrade
watchman watch-del-all
rm -rf $TMPDIR/react-*
cd android
then./gradlew clean
thencd ..
rm -rf node_modules && npm install
and thennpm start
Sometimes, you get into a loop where it seems like the app crashes on start no matter what you do. One approach to to take the the Root view back to basics and start a process of elimination. Below is a minimal Root view that you can paste in. You should also uninstall the app and run react-native run-android
import React from "react";
import { View, Text } from "react-native";
const Root = () => <View><Text>Test!</Text></View>;
export default Root;
note: the keystore file is not in Git. It is in 1password.
- Change version number in
package.json
npm run build
- In Chrome, open https://play.google.com/apps/publish/?account=8124299321342365078#AppDashboardPlace:p=com.optek.guitartunes
- Release Management
- App releases
- Manage Alpha (or Beta)
- Hit Create Release button
react-native run-android --variant=release
to test the buildopen android/app/build/outputs/apk/
to find the release apk
Version is set via package.json
with this technique
React Native uses Flexbox for layout. There is one caveat:
Flexbox works the same way in React Native as it does in CSS on the web, with a few exceptions. The defaults are different, with flexDirection defaulting to column instead of row, and the flex parameter only supporting a single number.