When trying to run react-native run-android on a linux machine I get the above error,
The error is not related to hot reloading as it appears at the first attempt to debug the app
import React, { Component } from 'react';
import { StatusBar, Dimensions, ImageBackground, Alert } from 'react-native';
import AsyncStorage from '@react-native-community/async-storage';
import { View, Text, Spinner, Button } from 'native-base';
import { baseUrl } from '../shared/baseUrl';
import { User } from './Models/User';
import { GlobalFont } from 'react-native-global-font';
export default class Login extends Component {
constructor(props) {
super(props);
this.state = {
loading: true,
phone: '',
password: '',
loginButtonContent: () => null
}
}
...........
<View keyboardVerticalOffset={-100} behavior="padding" style={{ flex: 1 }}>
<StatusBar translucent={true} backgroundColor="transparent" barStyle="light-content" />
<ImageBackground
progressiveRenderingEnabled={true}
source={require('./images/login-background.png')}
resizeMode="cover"
style={{ padding: 0, borderRadius: 0, height: Dimensions.get('window').height, width: Dimensions.get('window').width, flex: 1, justifyContent: "center" }} >
<View style={{ padding: 36, paddingTop: Dimensions.get('window').height / 2, justifyContent: "center", flex: 1, margin: 0 }}>
..........
</View>
</ImageBackground >
</View>
);
}
}
React Native Environment Info:
System:
OS: Linux 4.14 Manjaro Linux undefined
CPU: (4) x64 Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz
Memory: 375.55 MB / 7.69 GB
Shell: 4.4.23 - /bin/bash
Binaries:
Node: 10.10.0 - /usr/bin/node
npm: 6.4.1 - /usr/bin/npm
IDEs:
Android Studio: 3.3
npmPackages:
react: 16.8.3 => 16.8.3
react-native: 0.59.1 => 0.59.1
npmGlobalPackages:
create-react-native-app: 2.0.2
react-native-cli: 2.0.1
Hello there 👋 this issue doesn't have a repro (which means, a react-native init-ed project with the minimal changes that leads to creating the same issue you are reporting). Unfortunately, I have no way of helping you in a meaningful way – there is no easy way for me to recreate the situation and check that the issue reported is still there when changing the code.
Also, it seems to be actually related to/caused by Metro, would you mind, after creating a repro, open an issue there? https://github.com/facebook/metro/
for me the error was because of faulty imports of component i.e in Correct Path or file name, in my case I was importing like
import xyz from 'Components/xyz'
instead of
import xyz from './Components/xyz'
Such a silly mistake but it wasted my whole day
Closing the existing chrome debugger and opening a new one fixed for me.
Just kill the 'metro bundler' window and re-run the project ex: 'react-native run-android'. If you have debugger window open then refresh that too.
This worked for me. Try starting from 6) first, to see if it really is just a case of needing to stash / pop changes. If that doesn't work start from 1):
6) git stash ALL changes
7) Refresh iOS (app loaded again, without issues, at latest git commit)
8) pop / apply latest git stash (app loads and works fine without any changes to the code that broke the app.... ???)
1) Close chrome debugger
2) Close react-native electron debugger
3) Kill any open processes (e.g. abd kill-server)
4) On iOS emulator => menu > Hardware > "Erase All Content and Settings" > wait til emulator restarts
5) react-native run-ios > wait till loads > still get same error appearing on refreshed iOS app!!!
Most helpful comment
Closing the existing chrome debugger and opening a new one fixed for me.