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

React Native应用运行卡顿求助:执行react-native run-android后应用卡住

Fixing React Native App Stuck After react-native run-android

Hey there! Sorry to hear your React Native Android app is freezing up right after running react-native run-android—let’s go through some tried-and-true fixes that typically resolve this kind of issue.

Common Troubleshooting Steps

1. Restart the Metro Bundler (with Cache Reset)

More often than not, the Metro server gets stuck in a bad state or holds onto stale cached data. Here’s how to reset it:

  • Close any open Metro terminal processes completely.
  • Open a new terminal in your project root, run:
    react-native start --reset-cache
    
  • Once Metro is up and running smoothly, open another terminal and re-run:
    react-native run-android
    

The --reset-cache flag is critical here—it clears out old JavaScript and asset caches that frequently cause startup hangs.

2. Check Your Android Device/Emulator

If the app is getting stuck on the device side, try these quick checks:

  • Emulator users: Restart your emulator (sometimes it’s just starved for resources). You can also head to the AVD Manager and increase the emulator’s allocated RAM/CPU—too little memory will make apps freeze on launch.
  • Physical device users: Double-check that USB debugging is enabled on your device, then run adb devices to confirm your computer detects it. If not, re-plug the USB cable or toggle USB debugging off and on again.

3. Clean Project Builds & Caches

Corrupted build files are another common culprit:

  • Navigate to your project’s Android directory and clean the Gradle build:
    cd android && ./gradlew clean
    
  • Go back to the root directory and clear your package manager cache:
    # For npm users
    npm cache clean --force
    
    # For yarn users
    yarn cache clean
    
  • Now rebuild the app with react-native run-android.

4. Verify Dependency Version Compatibility

Mismatched versions of React Native, Android Gradle Plugin (AGP), or Gradle itself can lead to silent startup failures:

  • Check the official React Native documentation for your RN version to confirm the recommended AGP and Gradle versions.
  • Update android/build.gradle (for AGP) and android/gradle/wrapper/gradle-wrapper.properties (for Gradle) to match the recommended versions, then re-run the build.

5. Dig Into Debug Logs

If none of the above works, we need to pinpoint the exact error:

  • Run the build with verbose logging to see detailed output:
    react-native run-android --verbose
    
  • Or open your project’s android folder in Android Studio, go to the Logcat tab, and filter for your app’s package name. Look for red-marked error messages that pop up when the app gets stuck—this will lead you to the root cause (e.g., missing permissions, faulty native modules, etc.).

If you try all these steps and still have issues, share the relevant log snippets, and we can narrow it down further!

内容的提问来源于stack exchange,提问作者EDISON J

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.11 08:32:52