2016-02-24 186 views
4

我最近升級到RN 0.20,當我嘗試加載我的應用我現在有以下拋出的異常:陣營Android本地:screenPhysicalPixels.width未定義

undefined is not an object (evaluating 'screenPhyisicalPixels.width') 
<unknown> 
index.android.bundle?platform=android& def=true:32950 
requireImpl 
index.android.bundle?platform=android& def=true:76 
_require 
index.android.bundle?platform=android& def=true:36 

這顯然會導致JS錯誤以下文件:

node_modules/react-native/Libraries/Utilities/Dimensions.js at line 30 

有關信息,我不使用Dimensions API在我的應用程序。

對此有何建議?

回答

0

我不清楚是什麼命令做究竟是什麼,但我通過以下步驟修復了它,這要歸功於@ mr-brown和@ matija-grcic答案的組合:

  1. package.json
  2. 設置"react-native": "^0.20.0",刪除node_modules
  3. 運行react-native upgrade(更新等等​​)
  4. 我的手機上卸載應用程序
  5. react-native run-android
0

要做的最好的事情是刪除node_modules文件夾。在根目錄下運行後

watchman watch-del-all 

下一步是運行

npm install 

然後用

react-native start --reset-cache 

手動啓動打包那是什麼幫助我。祝你好運!

7

您需要更新串的Android /應用/的build.gradle

dependencies { 
    compile "com.facebook.react:react-native:0.20.+" 
} 

然後只需運行

npm start 
react-native run-android 
1

我從0.19升級我的項目時,也有類似的問題到0.20

這對我來說是什麼,運行的是react-native upgrade

之後,您可能需要重新安裝模塊npm install

編輯:當然,通過react-native run-android重建您的應用程序。

相關問題