React Native Android programs run error: React Native version mismatch

1. Problem:
React Native there is no problem with the development of Android, packaged signature APK, which can run normally, but run the program in development mode directly through the command line react-native run-android in the project. After the program starts, an error is reported:

React Native version mismatch.

JavaScript version: 0.54.3
Native version: 0.55.3
Make sure that you have rebuilt the native code. If the problem persists try clearing the Watchman and packager caches with `watchman watch-del-all && react-native start --reset-cache`.
  reactConsoleErrorHandler    
  checkVersions    
  (anonymous function)    
  loadModuleImplementation    
  guardedLoadModule    
  _require    
  (anonymous function)    
  executeApplicationScript    
  (anonymous function)    
regeneratorRuntime is not defined
  handleException    
  handleError    
  reportFatalError    
  guardedLoadModule    
  _require    
  (anonymous function)    
  executeApplicationScript    
  (anonymous function)    
Failed to print error: 

the reason is unknown.
try to delete and install node_modules as a whole, which is not easy to use.
what is the cause of this problem and how to fix it?

Mar.11,2021

this problem has been solved. Refer to the problem on stackoverflow: https://stackoverflow.com/que.
the cause of this problem lies in app/build.gradle in the Android project. The configuration for the version of the react-native library in build.gradle is written by default:

compile 'com.facebook.react:react-native:+'

the last "+" indicates the use of the latest version number.
that is, in our Android project, the native code version number of the dependent React native is the latest version released on the network.
this is also the root cause of our problem.
make the following changes according to the answers to the questions in the link above:

compile ('com.facebook.react:react-native:0.54.3') { force = true }

execute react-native run-android again, and everything returns to normal. It was such a big pit that I wasted the whole morning.

add: there is another situation in which
reports this error, that is, we first run other projects of different RN versions with react-native run-android . At this time, if we do not close the debugging process of other running RN projects and run the react-native run-android command under the project we want to start, we will also report this error in the installed app. That is, the answer with the largest number of votes in the stack overflow link.

to sum up:
this error may occur in two cases:
the first and more common case is that other projects with different RN version numbers are running in development mode, and this error will be reported if we run the project we want to debug with react-native run-android . The second case of
may be less common than the first, because the Native version library of RN may not necessarily be updated during our development cycle. In the second case, the version of the RN library that we configured in the Android project is not consistent with the version of the RN library configured in the JS project. In this case, just change the default configuration of the RN library under android/app/build.gradle to:

compile ('com.facebook.react:react-native:0.54.3') { force = true } // 0.54.3 JS
The

problem can be solved.

Menu