React native卡在旧版应用程序中

时间:2017-07-13 08:00:14

标签: react-native

当我运行 react-native run-android 时,它只会在模拟器中安装旧版本的应用程序并且不会显示更改。

任何建议都表示赞赏。

9 个答案:

答案 0 :(得分:16)

似乎我们每次将它们编译到android应用程序时都必须重新捆绑资产。这对我有用:

  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
    
  2. 然后:

    react-native run-android
    

答案 1 :(得分:4)

您是否尝试过react-native start --reset-cache

或许您可以尝试重置MAX_WAIT_TIME(我发现它here)。 在档案\node_modules\node-haste\lib\FileWatcher\index.js 你应该增加MAX_WAIT_TIME变量(例如:360000)并更改函数_createWatcher.

自:

key: '_createWatcher',
value: function _createWatcher(rootConfig) {
  var watcher = new WatcherClass(rootConfig.dir, {
    glob: rootConfig.globs,
    dot: false
  });
  return new Promise(function (resolve, reject) {
    var rejectTimeout = setTimeout(function () {
      return reject(new Error(timeoutMessage(WatcherClass)));
    }, MAX_WAIT_TIME);
    watcher.once('ready', function () {
      clearTimeout(rejectTimeout);
      resolve(watcher);
    });
  });
}

要:

key: '_createWatcher',
value: function _createWatcher(rootConfig) {
  var watcher = new WatcherClass(rootConfig.dir, {
    glob: rootConfig.globs,
    dot: false
  });

  return new Promise(function (resolve, reject) {

    const rejectTimeout = setTimeout(function() {
      reject(new Error([
        'Watcher took too long to load',
        'Try running `watchman version` from your terminal',
        'https://facebook.github.io/watchman/docs/troubleshooting.html',
      ].join('\n')));
    }, MAX_WAIT_TIME);

    watcher.once('ready', function () {
      clearTimeout(rejectTimeout);
      resolve(watcher);
    });
  });
}

可以帮到你! :d

答案 2 :(得分:1)

检查VS代码可能未突出显示的任何语法错误。

拉扯我的头发三个小时后,它并没有提醒我注意对象中的=而不是:

答案 3 :(得分:0)

尝试了上述解决方案,不确定它们是否对最终版本有所帮助,但是最后起作用的是在./gradlew clean assembleRelease文件夹中运行/android

答案 4 :(得分:0)

对我来说,我只是重新启动了系统。或者只是停止本机服务器,然后重新运行您的应用。

答案 5 :(得分:0)

在使用iOS时发生了这种情况,这是我恢复工作顺序所采取的步骤:

$ react-native start --reset-cache
$ rm -rf ios/build

单独执行此操作将强制RN在运行 yarn ios 时从头开始重建iOS版本,因此这可能是大多数其他使用iOS运行的人的答案。

在此问题的最新遭遇中,我发现在强制执行新的构建后,metro-bundler将引发以下错误: Metro Bundler遇到了错误:文件SHA-1(

有了这个,我必须刷新我的node_modules才能完全解决问题。

$ rm -r node_modules
$ yarn

答案 6 :(得分:0)

Use reload option from expo, by dragging from icon bar

通过从图标栏拖动,使用博览会的重装选项

答案 7 :(得分:0)

在我的案例中,一位同事在导入React之前从React Native导入了组件。导入顺序很重要。

那应该是这样的:

import React from "react";
import { View, Text } from "react-native";

答案 8 :(得分:0)

解决此问题的另一种方法是在 Web 浏览器控制台中运行此命令。我在使用 React Native for Windows 时遇到了这个问题,而且上述解决方案都不适合我。

localStorage.clear()
相关问题