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

React Native版本不匹配(JS V:0.49.3 RN V:0.59.9)问题求助

Fixing React Native Version Mismatch (JS V:0.49.3 / RN V:0.59.9) on Android

Hey there! I totally get how frustrating this is—iOS runs fine, you can build an APK, but debugging mode via react-native run-android throws that version mismatch error. Let's walk through targeted fixes since the usual "close terminals" and basic cache resets didn't work:

Step 1: Wipe All Metro & Project Caches Completely

Metro Bundler and watchman can hold onto old cached data that doesn't clear with a simple reset. Run these commands in your project root:

  • Stop any running Metro or React Native processes first (check your task manager if you're unsure!)
  • watchman watch-del-all (clears watchman's file watch cache)
  • rm -rf node_modules
  • npm install (or yarn install if you use yarn)
  • rm -rf $TMPDIR/react-*
  • rm -rf $TMPDIR/metro-*
  • npx react-native start --reset-cache (start Metro with a full cache reset)

Step 2: Verify Android Project RN Version Configs

Sometimes the Android Gradle files don't sync properly with your package.json version. Double-check these files:

  • Open android/app/build.gradle: Look for the line implementation "com.facebook.react:react-native:+". Replace the + with your exact RN version 0.59.9 to avoid Gradle pulling an outdated version.
  • Check android/build.gradle: Ensure the buildscript and allprojects sections don't have hardcoded references to 0.49.3 anywhere.

Step 3: Clean Android Gradle Cache

Gradle's cache is a common culprit for version mismatches on Android. Run:

  • cd android && ./gradlew clean (use gradlew clean on Windows)
  • Optionally, delete the .gradle folder inside your project's android directory, or even the global Gradle cache at ~/.gradle/caches (note: this clears cache for all your Gradle projects, but can fix stubborn issues)

Step 4: Delete Old Android Bundle Files

If an outdated debug bundle is lingering, it can cause version conflicts:

  • Navigate to android/app/src/main/assets and delete any existing index.android.bundle or index.bundle files.
  • Generate a fresh debug bundle with:
    npx react-native bundle --platform android --dev true --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/
    

Step 5: Check Node Version Compatibility

React Native 0.59.9 works best with Node.js versions 8.x to 10.x. If you're using a newer Node version, it might cause dependency or packaging issues:

  • Use a version manager like nvm to switch to a compatible version (e.g., nvm install 10.24.1 then nvm use 10.24.1)
  • Reinstall your dependencies after switching Node versions

Step 6: Re-Run the Project

Once all the above steps are done, try running:

npx react-native run-android --reset-cache

Or start Metro first with npx react-native start --reset-cache, then run npx react-native run-android in a separate terminal.

A quick note on why iOS works: iOS uses CocoaPods for dependency management, which tends to sync versions more reliably than Android's Gradle. Plus, iOS's cache system is isolated from Android's, so the old version data doesn't carry over.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.13 09:13:18