◉RORK LABJP
●GPT-6.1 SOL — Added to Rork's model menu (09-29) with Low, Medium and High effort; included on Pro and Max●SONNET 5.5 — Claude Sonnet 5.5 is selectable: strong at UI design and faster than Sonnet 5 (09-28)●SDK 58 — Beta since 09/15 with no stable date yet; running projects in Expo Go has required login since 09/03●WIDGET — A write-up traces an iOS widget that renders black only in production builds●OBSERVE — EAS Observe now records native crashes too (SDK 57.0.21 or later, 10/07)●NEW — My App Open Ad Only Showed When the App…●GPT-6.1 SOL — Added to Rork's model menu (09-29) with Low, Medium and High effort; included on Pro and Max●SONNET 5.5 — Claude Sonnet 5.5 is selectable: strong at UI design and faster than Sonnet 5 (09-28)●SDK 58 — Beta since 09/15 with no stable date yet; running projects in Expo Go has required login since 09/03●WIDGET — A write-up traces an iOS widget that renders black only in production builds●OBSERVE — EAS Observe now records native crashes too (SDK 57.0.21 or later, 10/07)●NEW — My App Open Ad Only Showed When the App…
Articles/Dev Tools
⬡ Dev Tools/2026-04-19Intermediate

Rork App Works in Preview But Crashes on Device — Here's Why

Your Rork-generated app runs fine in preview but crashes on a real device. This guide covers the four most common causes: missing env vars, native module version mismatches, permission config gaps, and async initialization issues.

troubleshooting69crash7expo12rork-max40native3debug

"Works perfectly in Rork preview, crashes immediately on my phone" — this is one of the most common issues developers run into when taking a Rork-generated app off the preview platform and onto a real device.

The gap exists because Rork's preview environment handles several things automatically that you need to configure explicitly for a real build: environment variables, native module versions, platform permissions. Once you know these four patterns, most crashes resolve quickly.

Identify the Crash Type First

Different crash patterns point to different causes, so observation saves time:

  • Crashes immediately on launch → Missing environment variables or native module initialization failure
  • Crashes on a specific action → Bug in that specific code path or API
  • Crashes only on iOS (or only Android) → Platform-specific permissions or native API differences
  • Works on Expo Go but crashes in a standalone build → Missing native plugin configuration in app.json

Fix 1: Missing Environment Variables

Rork's preview environment automatically injects environment variables you set in the project settings. A real device build doesn't get those automatically.

When you see this in crash logs:

TypeError: undefined is not an object (evaluating 'process.env.EXPO_PUBLIC_API_KEY.length')

For local testing with Expo Go, create .env.local in your project root:

# .env.local — local device testing
EXPO_PUBLIC_API_KEY=your_actual_api_key_here
EXPO_PUBLIC_SUPABASE_URL=https://your-project.supabase.co
EXPO_PUBLIC_SUPABASE_ANON_KEY=your_anon_key_here

For EAS Build (App Store submission), add to eas.json or use the EAS dashboard:

{
  "build": {
    "production": {
      "env": {
        "EXPO_PUBLIC_API_KEY": "your_production_api_key"
      }
    }
  }
}

Add a guard in your code to get a clear error message instead of a cryptic crash:

const apiKey = process.env.EXPO_PUBLIC_API_KEY;
if (\!apiKey) {
  console.error('API key is not configured. Check your .env file.');
  // Show an error screen instead of crashing
}

Fix 2: Native Module Version Mismatches

Rork-generated code uses Expo SDK packages like expo-camera, expo-location, and expo-notifications. If the versions in package.json don't match what your Expo SDK version expects, the app will crash on launch.

# Check your current Expo SDK version
cat package.json | grep '"expo":'
 
# Fix all package versions to be compatible with your Expo SDK
npx expo install --fix
 
# Reinstall the most crash-prone native packages explicitly
npx expo install expo-notifications expo-camera expo-location expo-image-picker

expo-notifications and expo-camera are the most frequent culprits for version-related crashes. Running npx expo install --fix after cloning or after Rork regenerates the project usually resolves it.

Fix 3: Missing iOS/Android Permission Configuration

If your app uses camera, location, microphone, or notifications, iOS and Android both require explicit permission strings in your native configuration. Rork's generated app.json sometimes leaves these out.

{
  "expo": {
    "ios": {
      "infoPlist": {
        "NSCameraUsageDescription": "Used to take photos in the app",
        "NSLocationWhenInUseUsageDescription": "Used to show your location on the map",
        "NSMicrophoneUsageDescription": "Used for voice input"
      }
    },
    "android": {
      "permissions": [
        "CAMERA",
        "ACCESS_FINE_LOCATION",
        "RECORD_AUDIO"
      ]
    },
    "plugins": [
      ["expo-camera", { "cameraPermission": "Used to take photos" }],
      ["expo-location", { "locationWhenInUsePermission": "Used to show your location" }]
    ]
  }
}

Without these, iOS silently denies the permission request and crashes instead of showing a dialog. On Android, you'll see SecurityException in the logs.

Fix 4: Async Initialization Timing Issues

On a real device, app startup can be slightly slower, which exposes race conditions in async initialization code. If you try to access Supabase or Firebase data before the client has finished initializing, you'll get a crash that never appeared in preview.

// ❌ Risky: fetches data before client might be ready
useEffect(() => {
  fetchUserData(); // supabase client might not be initialized yet
}, []);
 
// ✅ Wait for initialization to complete
const [isReady, setIsReady] = useState(false);
 
useEffect(() => {
  const initialize = async () => {
    await supabase.auth.getSession(); // Ensure client is ready
    setIsReady(true);
  };
  initialize();
}, []);
 
if (\!isReady) {
  return <LoadingScreen />;
}

Reading Crash Logs

For crashes you can't reproduce easily, logs are your best tool.

iOS — Open Xcode, go to Window → Devices and Simulators, select your device, click View Device Logs. Filter by your app bundle ID.

Android — With the device connected via USB:

adb logcat *:E | grep "ReactNative\|expo\|your.app.bundle"

Expo Go — Shake the device to open the debug menu, enable Remote JS Debugging, then open Chrome's DevTools for live error output.

Start Here

When an app crashes on device but works in Rork preview, run through this in order:

  1. Check that all environment variables are configured for the real build environment
  2. Run npx expo install --fix to sync package versions
  3. Verify app.json has permission strings for every native feature you're using
  4. Read the device crash logs to get the actual error message

These four steps cover the vast majority of Rork-generated app crash scenarios. The patterns repeat across projects, so after hitting each one once, you'll recognize them immediately going forward.

Share

Thank You for Reading

Rork Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • ✦Copy-paste ready implementation code
  • ✦New advanced guides published daily
  • ✦$5/mo or $10 for lifetime access
View Membership →

If you found this article helpful, a small tip ($1.50) would mean a lot to us. Your support helps keep this site ad-free and covers server and hosting costs.

Related Articles

⬡ Dev Tools2026-05-20
Fixing 0x8badf00d Watchdog Kills That Wipe Out Rork Apps at Launch
Your Rork iOS app dies right after launch on real devices, but never on your bench. Crashlytics shows exception code 0x8badf00d. Here is how to read the exact watchdog budget out of the crash log and rearrange your launch path so it stops.
⬡ Dev Tools2026-05-15
Rork Max Android App Crashes Only on Older OS Versions: Java 8 Desugaring Fix
Diagnose why your Rork Max Android app crashes only on older OS versions (Android 6–8) and fix it permanently with Java 8 core library desugaring. Includes the two cases where the fix alone was not enough.
⬡ Dev Tools2026-10-07
Japanese Headings Won't Turn Bold on Android: How to Trace and Fix a fontWeight That Does Nothing
A troubleshooting note for Rork apps where headings look bold on iPhone but stay thin on Android. How to tell the symptoms apart, pick weights through fontFamily, and verify the fix.