1. 程式人生 > >ERROR: react-native version mismatch

ERROR: react-native version mismatch

React Native version mismatch.

JavaScript version: 0.55.4
Native version: 0.57.0
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: 

報上面的錯, 那是app的build.gradle配置有問題,解決方案如下:

implementation "com.facebook.react:react-native:+"

這個最後面的 “+” 表示的是使用最新的版本號。 也就是說,我們Android工程中,依賴的React native 的native程式碼版本號是使用網路上釋出的最新版本。 這也是我們這個問題產生的根本原因。 按照上面連結中的問題的回答,進行如下修改:

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

或者:

compile ('com.facebook.react:react-native:0.55.4') { force = true }  // 0.55.4 處變為自己的JS工程中的相應版本號