When I run react-native run-android it only installs the old version of the app in simulator and changes are not shown.
Any suggestion is appreciated.
Have you tried react-native start --reset-cache
?
Or maybe you can try to reset the MAX_WAIT_TIME
(I found it here).
in file \node_modules\node-haste\lib\FileWatcher\index.js
you should increase MAX_WAIT_TIME
variable (example : 360000) and change function _createWatcher.
From:
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);
});
});
}
To:
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);
});
});
}
May it help you! :D
For me I simply restarted my system. Or simply stop the react-native server, then re-run your app.
In my case a colleague imported components from React Native before he imported React. The order of your imports is important.
That's how it should look like:
import React from "react";
import { View, Text } from "react-native";
Seems like we have to re-bundle assets every time we compile it to android app. This worked for me:
First run this:
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
Then this:
react-native run-android
Use reload option from expo, by dragging from icon bar
I had this happen while working with iOS, and here are the steps I took to get back to working order:
$ react-native start --reset-cache
$ rm -rf ios/build
Doing this much on its own will force RN to rebuild the iOS version from scratch when you run yarn ios, so this could be answer for most anyone else running with iOS.
In my latest encounter of this issue, I found that after forcing a new build, metro-bundler would throw the following error: Metro Bundler has encountered an error: SHA-1 for file < some file in node_modules >
With this, I had to refresh my node_modules in order to resolve the issue completely.
$ rm -r node_modules
$ yarn