React Native Expo项目AppLoading加载异常求助:扫码启动报错空白
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
Imagesconstant exist at their specified paths. It's possible a file was accidentally moved or deleted without you noticing. - Temporarily comment out this line:
If the project loads after doing this, one of the images in your// articles.map(article => assetImages.push(article.image));articlesarray is broken (either a dead remote URL or invalid local path). Test eacharticle.imageone 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:
- Install the package:
expo install expo-splash-screen - Rewrite your loading logic to use the splash screen APIs to preload assets and hide the splash screen once ready.
内容的提问来源于stack exchange,提问作者Anuj Sharma

