反应本机代码更改不反映在设备上

时间:2019-05-30 12:06:52

标签: android reactjs react-native visual-studio-code

今天早上在病房,我遇到了与本机android build反应的问题。代码中的新更改未反映在设备上。没有构建失败。我尝试了以下

  • 删除并重新安装节点模块
  • 本机链接
  • ./ gradlew clean
  • react-native bundle --platform android --dev false --entry-file index.js --bundle-output android / app / src / main / assets / index.android.bundle --assets-dest android / app / src / main / res
  • watchman关机服务器
  • rm -rf / usr / local / var / run / watchman && brew卸载watchman && brew安装watchman
  • npm start---reset-cache

我的package.json

{
"name": "",
"version": "0.0.1",
"private": true,
"scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest",
    "ipad": "react-native run-ios --simulator 'iPad Pro (10.5-inch) (12.0)' --configuration Debug"
},
"dependencies": {
    "@babel/runtime": "^7.2.0",
    "accordion-collapse-react-native": "^0.1.9",
    "aws-amplify": "^1.1.18",
    "aws-amplify-react-native": "^2.1.6",
    "aws-sdk": "^2.394.0",
    "buffer": "^5.2.1",
    "i18next": "^12.1.0",
    "moment": "^2.24.0",
    "nanoid": "^2.0.0",
    "native-base": "^2.8.1",
    "react": "^16.6.3",
    "react-i18next": "^8.3.8",
    "react-native": "^0.57.8",
    "react-native-app-intro-slider": "^2.0.1",
    "react-native-check-box": "^2.1.7",
    "react-native-collapsible": "^1.4.0",
    "react-native-fetch-blob": "^0.10.8",
    "react-native-gesture-handler": "^1.0.10",
    "react-native-image-crop-picker": "^0.21.3",
    "react-native-image-resizer": "^1.0.0",
    "react-native-img-button": "^1.0.1",
    "react-native-keyboard-aware-scroll-view": "^0.8.0",
    "react-native-keyboard-manager": "^4.0.13-10",
    "react-native-keyboard-spacer": "^0.4.1",
    "react-native-languages": "^3.0.1",
    "react-native-linear-gradient": "^2.5.3",
    "react-native-locale-detector": "^1.0.1",
    "react-native-material-dropdown": "^0.11.1",
    "react-native-material-ripple": "^0.8.0",
    "react-native-modal-datetime-picker": "^6.0.0",
    "react-native-paper": "^2.15.2",
    "react-native-segmented-control-tab": "^3.3.1",
    "react-native-signature-pad-react-16": "^0.4.0",
    "react-native-size-matters": "^0.1.4",
    "react-native-vector-icons": "^6.1.0",
    "react-navigation": "^2.18.2",
    "react-redux": "^5.1.1",
    "redux": "^4.0.1",
    "redux-thunk": "^2.3.0",
    "remote-redux-devtools": "^0.5.16",
    "rnkit-alert-view": "^0.1.2"
},
"devDependencies": {
    "babel-jest": "23.6.0",
    "jest": "23.6.0",
    "metro-react-native-babel-preset": "0.49.2",
    "react-test-renderer": "16.6.1"
},
"jest": {
    "preset": "react-native"
},
"rnpm": {
    "assets": [
        "./src/assets/fonts"
    ]
}
}

1 个答案:

答案 0 :(得分:1)

请勿使用react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res来运行Android本机响应。此命令将JS服务器捆绑在包(APK)中。因此,将不会与在系统上运行的Metro服务器进行通信。

使用react-native run-android命令调试应用程序。在此js服务器中将不附带软件包。因此,更改将反映在刷新应用程序时