This guide will help you set up and run a React Native for Android development.
Ensure you have the following installed:
- Node.js (Recommended: v18+)
- React Native CLI
npm install -g react-native-cli
- Java Development Kit (JDK) (Recommended: OpenJDK 17)
- Android SDK & Build Tools
- Add the following paths to your system’s environment variables:
ANDROID_HOME=$HOME/Library/Android/sdk PATH=$PATH:$ANDROID_HOME/emulator PATH=$PATH:$ANDROID_HOME/platform-tools
- For Windows:
- Add
C:\Users\YourUser\AppData\Local\Android\Sdk
to the system variables.
- Add
npx react-native start
npx react-native run-android
If the build fails, try cleaning and rebuilding:
cd android && ./gradlew clean && cd ..
npx react-native run-android
Gradle Build Failed
- Run:
cd android && ./gradlew clean && cd ..
- Ensure
gradle.properties
has:
android.useAndroidX=true
android.enableJetifier=true
- Run:
cd android
./gradlew assembleDebug