You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

React Native Expo项目AppLoading加载异常求助:扫码启动报错空白

Fixing "AppLoading threw an unexpected error when loading" in Your Expo React Native Project

Let's break down how to debug and fix this issue step by step—since your project worked fine before, the problem is likely a small, easy-to-miss detail:

1. First, Fix Your Error Logging to See the Real Issue

Looking at your code, the _handleLoadingError method uses warn(error) which isn't a valid function in React Native. That means you're not seeing the actual error that's breaking the load process! Update this method to log the full error details:

_handleLoadingError = error => {
  // 此时可将错误上报至错误追踪服务,例如Sentry
  console.warn('Resource loading failed:', error);
};

Now when you run the project, your terminal will show exactly what's going wrong (e.g., a missing image, invalid asset path, etc.)—this is the most critical first step.

2. Validate Your Image Resources

The error is happening during image caching, so let's check those assets:

  • Double-check that all images in your Images constant exist at their specified paths. It's possible a file was accidentally moved or deleted without you noticing.
  • Temporarily comment out this line:
    // articles.map(article => assetImages.push(article.image));
    
    If the project loads after doing this, one of the images in your articles array is broken (either a dead remote URL or invalid local path). Test each article.image one by one to find the culprit.

3. Clear Expo's Cache

Cached assets can sometimes get corrupted, even if you didn't change code. Run this command to reset everything:

expo r -c

This restarts the Expo server and wipes all cached assets—often fixes weird, unexplained loading failures.

4. Check for Version Mismatches

  • Make sure your phone's Expo Client app is up to date. Old client versions can have compatibility issues with your project's Expo SDK.
  • If you suspect dependency issues, reinstall your project's dependencies to ensure everything is properly linked:
    npm install
    # Or use yarn if that's your package manager
    yarn install
    

5. Switch to Expo Splash Screen (Alternative Fix)

If AppLoading keeps causing issues, consider migrating to expo-splash-screen—it's the official, more stable replacement for AppLoading recommended by Expo. You'll need to:

  1. Install the package: expo install expo-splash-screen
  2. Rewrite your loading logic to use the splash screen APIs to preload assets and hide the splash screen once ready.

内容的提问来源于stack exchange,提问作者Anuj Sharma

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.06 17:47:41