Day078 — How to build your React Native
2 min readMay 20, 2019
There are two ways to build a React Native application.
- with expo-cli
- with react-native-cli
I use the second method to build an android app. That kind of app is called an ejected app, which means it is ejected from the expo eco-system. It is when you want to use a library that requires you to run react-native link
to link your library. More on ejecting.
Steps to build apk or ipa
npm install
react-native eject
react-native link
react-native run-android
orreact-native run-ios
Important notes
- make sure you have java 8 jdk installed. instructions
- make sure you have android sdk installed and its path correctly configured. instructions
- run
chmod 755 android/gradlew
if encounter this issue - set android path
Download JDK
Otherwise below error occurs.
* What went wrong:
Could not determine java version from '12.0.1'.
Set android path
add below to .bash_profile or .zshrc
export ANDROID_HOME=$HOME/Library/Android/sdk export PATH=$PATH:$ANDROID_HOME/emulator export PATH=$PATH:$ANDROID_HOME/tools export PATH=$PATH:$ANDROID_HOME/tools/bin export PATH=$PATH:$ANDROID_HOME/platform-tools
To run React Native on Windows
- clone repo
- run
npm install -g react-native-cli
to install react-native-cli globally - run
yarn install
- run
yarn start
on one terminal and runyarn start-android
on another terminal
To solve “SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.” problem
- create
local.properties
under./android
- write
sdk.dir=C\:\\Users\\USERNAME\\AppData\\Local\\Android\\sdk
to define location of android sdk. ref: StackOverflow
To solve “Could not find tools.jar. Please check that C:\Program Files (x86)\Java\jre1.8.0_201 contains a valid JDK installation” problem
- reinstall jdk 8 — Java SE Development Kit 8u201, ref StackOverflow
To solve “com.android.builder.testing.api.DeviceException: com.android.ddmlib.InstallException: INSTALL_FAILED_UPDATE_INCOMPATIBLE: Package com.agwmmmusic signatures do not match previously installed version; ignoring!” problem
- uninstall any previously built app on device
To solve “‘adb’ is not recognized as an internal or external command, operable program or batch file.” problem
- put
C:\Users\USERNAME\AppData\Local\Android\Sdk\platform-tools
to Path in Environment Variables