React Native Android Studio无法连接开发服务器,重装node_modules遇XML解析错误
Hey there, I’ve dealt with this exact error a few times when working on React Native Android projects, so let me break down what’s going on and how to fix it quickly.
What’s Causing This Error?
The error message points to a syntax mistake in your AndroidManifest.xml file. The sax parser (used by React Native’s CLI to read the Android manifest) is throwing a fit because it found a forward slash in an opening tag that isn’t properly closed with a >. This usually happens when you have a self-closing tag written incorrectly—like <uses-permission/ instead of <uses-permission/>, or a random typo messing up the tag structure.
Step-by-Step Fix
Locate your AndroidManifest.xml
Navigate to this path in your project:android/app/src/main/AndroidManifest.xmlFix the XML syntax error
Jump to line 9 (as called out in the error log, column 42) and inspect the tag at that position:- Make sure all self-closing tags follow the format
<tagName/>(no missing closing>) - Double-check for typos, extra characters, or unclosed tags nearby
- If you’re stuck, copy the entire manifest content into an XML validator tool (search for one online) to pinpoint the exact issue automatically
- Make sure all self-closing tags follow the format
Clear cache and restart the dev server
After fixing the manifest, run these commands to wipe any cached data that might still be causing issues:npx react-native clean npx react-native start --reset-cacheRe-run your Android project
Finally, launch the app again with:npx react-native run-android
Why Did Reinstalling node_modules Trigger This?
Reinstalling dependencies didn’t actually create the XML error—it just forced the React Native CLI to re-parse your manifest file (since the CLI tools are part of node_modules). The syntax mistake was already in your manifest, but it might have been overlooked until the fresh install triggered a full validation check.
内容的提问来源于stack exchange,提问作者Awais Butt

