Getting Started with React Native Android
We're going to be use io.js because node has a lot of trouble with the
Download io.js - https://iojs.org/en/
brew install watchman brew install gradle brew install android-ndk brew install android-sdk sudo npm install -g react-native-cli
In your bash profile, export the android-sdk and android-ndk
export ANDROID_HOME=/usr/local/opt/android-sdk export ANDROID_NDK=/usr/local/Cellar/android-ndk/r10e
Go into the root of an app created using
react-native init and run:
git clone firstname.lastname@example.org:facebook/react-native.git cd react-native ./gradlew :Examples:Movies:android:app:installDebug # Start the packager in a separate shell (make sure you ran npm install): ./packager/packager.sh
This isn't recommended, but the route I went down first before discovering the prior method.
gradle # to build gradle assemble # to make unsigned apk
This will generate three files in
app-debug-unaligned.apk app-debug.apk app-release-unsigned.apk
Gotcha's for doing it the hard way
It might complain that you are missing some deps or build tools when trying to build or install, you can install them from the command line using:
sudo android update sdk --no-ui --all --filter build-tools-23.0.1 android update sdk --no-ui --filter 'platform-tools'
adb -d install /build/outputs/apk/app-debug.apk
The -d flag specifies that you want to use the attached device (in case you also have an emulator running).
See this when trying to run
Just delete the file node_modules/react-native/node_modules/react-tools/docs/js/react.js and everything is fine.