This guide explains how to run local build and deploy your React Native app directly to an Emulator or a physical Android device for local testing and development.
For Windows users, automated scripts are available:
REM Setup environment and load .env variables
scripts\windows\setup-test-env.bat
REM List available emulators
scripts\windows\setup-test-env.bat --list-emulators
REM Start emulator
scripts\windows\setup-test-env.bat --start-emulator Pixel_8_API_34
REM Start Appium server with inspector plugin
scripts\windows\setup-test-env.bat --start-appium
REM Stop Appium server
scripts\windows\setup-test-env.bat --stop-appium
REM Build and run E2E tests
scripts\windows\run-local-test-android.bat --build welcomeSee APPIUM_ANDROID_TESTING_WINDOWS.md for complete Windows testing guide.
- Mac/Windows/Linux with Android SDK installed
- Android device (phone/tablet)
- USB cable for device connection
- Android Developer options enabled on device
- Node.js and npm installed
- Java Development Kit (JDK) 17 installed (NOT Java 24+ which is incompatible)
It is beneficial to install Watchman to detect file changes automatically.
brew install watchmanWatchman is not available on Windows, and for Linux, please, refere to official documentation
It is recommended to install OpenJDK distribution called Azul Zulu for Android development when using Mac.
brew install --cask zulu@17- Download OpenJDK 17 from Eclipse Adoptium
- Install the MSI package
- Set JAVA_HOME in System Environment Variables
sudo apt update
sudo apt install openjdk-17-jdkjava -version
# Should show version 17.x.xIf you're starting with an Expo managed app, you need to eject first:
cd app
npx expo prebuild --platform androidThis creates the native Android project files in the android/ directory.
This will install all dependencies, build and run local build of the project in emulator (without Expo Go)
npx expo run:androidIf you encounter build errors or dependency conflicts, try these commands:
cd android && ./gradlew clean- Go to Settings → About Phone
- Tap "Build Number" 7 times until "You are now a developer" appears
- Go back to Settings → Developer Options
- Enable "USB Debugging"
- Enable "Install via USB" (if available)
- Connect your Android device to your computer via USB
- Select "File Transfer" or "PTP" when prompted on device
- Allow USB Debugging when the popup appears on your device
- Tap "Always allow from this computer" and then "OK"
cd app
npx react-native doctor
adb devicesYou should see your device listed in the output.
Clean and build the release APK:
cd android
./gradlew clean
./gradlew assembleReleaseThe APK will be generated at: android/app/build/outputs/apk/release/app-release.apk
Note: For production releases, you'll want to sign your APK with a keystore. For development and testing, the unsigned release APK works fine.
Verify your device is connected and install the APK:
# Check device connection
adb devices
# Install the release APK
adb install app/build/outputs/apk/release/app-release.apkThe app should appear in your device's app drawer. Tap to launch.
- Standalone app - No need for Metro bundler or computer connection
- Optimized performance - JavaScript bundle is compiled and minified
- Production-ready - Same configuration used for Play Store builds
- Offline capable - Works without any development server
- Smaller size - Dead code elimination and optimizations applied
- Backup your keystore file - Store it securely
- Remember your passwords - Write them down safely
- Never commit keystore to version control
Create android/gradle.properties (if not exists):
MYAPP_UPLOAD_STORE_FILE=my-upload-key.keystore
MYAPP_UPLOAD_KEY_ALIAS=my-key-alias
MYAPP_UPLOAD_STORE_PASSWORD=*****
MYAPP_UPLOAD_KEY_PASSWORD=*****Update android/app/build.gradle:
android {
...
signingConfigs {
release {
if (project.hasProperty('MYAPP_UPLOAD_STORE_FILE')) {
storeFile file(MYAPP_UPLOAD_STORE_FILE)
storePassword MYAPP_UPLOAD_STORE_PASSWORD
keyAlias MYAPP_UPLOAD_KEY_ALIAS
keyPassword MYAPP_UPLOAD_KEY_PASSWORD
}
}
}
buildTypes {
release {
...
signingConfig signingConfigs.release
}
}
}This means you're using Java 24+ which is not supported by Gradle.
Solution:
- Install Java 17 (see Prerequisites section)
- Set JAVA_HOME correctly:
# macOS (Homebrew) export JAVA_HOME=/opt/homebrew/opt/openjdk@17/libexec/openjdk.jdk/Contents/Home # Windows set JAVA_HOME=C:\Program Files\Eclipse Adoptium\jdk-17.x.x-hotspot # Linux export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
- Stop Gradle daemons and try again:
cd android ./gradlew --stop ./gradlew clean
java -version
echo $JAVA_HOME # macOS/Linux
echo %JAVA_HOME% # WindowsSolution:
- Set ANDROID_HOME:
# macOS export ANDROID_HOME=~/Library/Android/sdk # Windows set ANDROID_HOME=%LOCALAPPDATA%\Android\Sdk # Linux export ANDROID_HOME=~/Android/Sdk
- Add to PATH:
export PATH=$PATH:$ANDROID_HOME/emulator:$ANDROID_HOME/platform-tools
Add these lines to your shell profile:
macOS/Linux (~/.zshrc or ~/.bashrc):
export JAVA_HOME=/opt/homebrew/opt/openjdk@17/libexec/openjdk.jdk/Contents/Home
export ANDROID_HOME=~/Library/Android/sdk
export PATH=$JAVA_HOME/bin:$PATH:$ANDROID_HOME/emulator:$ANDROID_HOME/platform-toolsWindows (System Environment Variables):
JAVA_HOME:C:\Program Files\Eclipse Adoptium\jdk-17.x.x-hotspotANDROID_HOME:%LOCALAPPDATA%\Android\Sdk- Add to
PATH:%JAVA_HOME%\bin;%ANDROID_HOME%\emulator;%ANDROID_HOME%\platform-tools
# Stop all Gradle daemons
./gradlew --stop
# Clean project
./gradlew clean
# Check Gradle status
./gradlew --status
# Build with debug info
./gradlew assembleRelease --info# macOS/Linux
rm -rf ~/.gradle/caches/
# Windows
rmdir /s "%USERPROFILE%\.gradle\caches"- Enable Developer Options and USB Debugging
- Try different USB cable or USB port
- Install device drivers (Windows)
- Revoke USB debugging authorizations in Developer Options, then reconnect
- Check:
adb devicesshould list your device
- Uninstall existing app from device first
- Different signing keys between debug and release builds
- Clear app data before installing
- Clean project:
cd android && ./gradlew clean - Check Java version: Ensure JDK 17 is installed and JAVA_HOME is set
- Stop Gradle daemons:
./gradlew --stop - Update Android Gradle Plugin in
android/build.gradle - Check Gradle version compatibility
- Set JAVA_HOME environment variable correctly
- Use JDK, not JRE (Java Development Kit, not Runtime Environment)
- Verify Android SDK installation
- Enable "Install unknown apps" for your file manager
- Check device storage space
- Try installing with different ADB flags:
adb install -r app-release.apk(replace existing) - Check app permissions in device settings
- Check logs:
adb logcat | grep ReactNative - Verify all native dependencies are properly linked
- Clean and rebuild:
cd android && ./gradlew clean && ./gradlew assembleRelease
app/
├── android/ # Native Android project
│ ├── app/ # Main application module
│ │ ├── build.gradle # App-level build config
│ │ ├── src/main/AndroidManifest.xml # App manifest
│ │ ├── src/main/java/ # Java/Kotlin source
│ │ ├── src/main/res/ # Resources (icons, strings)
│ │ └── build/outputs/apk/ # Generated APK files
│ ├── build.gradle # Project-level build config
│ ├── gradle.properties # Gradle configuration
│ └── settings.gradle # Project settings
├── src/ # React Native source code
└── package.json # Node.js dependencies
- Always use release builds for device deployment
- Enable ProGuard/R8 for code obfuscation and size reduction
- Generate App Bundle instead of APK for Play Store
- Test on multiple devices with different Android versions
- Monitor APK size - Use command line tools like
aaptto analyze APK
- Android 5.0+ (API level 21+) (minimum SDK version)
- ARM or x86 processor architecture
- USB debugging enabled
- Sufficient storage space for app installation
# List connected devices
adb devices
# Install APK
adb install path/to/app.apk
# Install APK replacing existing (if installed)
adb install -r path/to/app.apk
# Uninstall app
adb uninstall com.yourpackage.name
# View logs
adb logcat
# Clear app data
adb shell pm clear com.yourpackage.name
# Take screenshot
adb shell screencap /sdcard/screenshot.png
adb pull /sdcard/screenshot.pngNote: This guide focuses on Release builds for standalone deployment. No Metro bundler or Expo required after successful build.