React Native新手执行react-native run-android时遇启动错误码500求助
run-android Error Code 500 with Intent { cmp=com.MainActivity } Hey there! As someone who’s worked through plenty of React Native Android startup kinks, let’s get this sorted out for you. Even though your build succeeded, that error code 500 when launching the app usually points to an issue with how the app is being targeted or cached state. Here’s what to try:
Verify your MainActivity path in the Intent
The error showscmp=com.MainActivity—this is likely missing your project’s actual package name prefix. For example, if your project is namedMyAwesomeApp, the correct Intent should becmp=com.myawesomeapp.MainActivity. Check yourandroid/app/src/main/AndroidManifest.xmlto confirm the full package name for your MainActivity. You can also test launching the app manually by tapping its icon on the device/emulator; if it opens, the Intent path in the command is definitely the problem.Clean and rebuild your Android project
Cached build artifacts often cause weird startup glitches. Run these commands in order:cd android ./gradlew clean cd .. react-native run-androidThis wipes old build files and forces a fresh compile, which fixes many hidden issues.
Check your ADB connection
Make sure your device or emulator is properly connected:- Run
adb devicesto confirm the device shows up with adevicestatus (notunauthorizedoroffline). - If using an emulator, restart it; if using a physical device, re-plug the USB cable and double-check that USB debugging is enabled in developer options.
- Run
Restart the Gradle Daemon
Even though the build succeeded, a wonky Gradle daemon might be causing post-build issues. Stop it with:cd android ./gradlew --stopThen run
react-native run-androidagain to start fresh.
If none of these work, check your Logcat output (adb logcat) right after the error—this will show the exact exception that’s crashing the app on launch, which can point you to deeper issues like missing dependencies or misconfigured native modules.
内容的提问来源于stack exchange,提问作者gustavo delfim

