android - 开发服务器返回响应错误代码:500 - ReactNative
问题描述
我收到错误消息-
The development server returned response error code: 500
,
尝试使用运行 React Native 代码时
react-native run-android
.
我不知道如何解决这个错误(截图中的那个)。虽然,我试过 -
react-native start --reset-cache
adb 杀死服务器
adb 启动服务器
adb 反向 tcp:8081 tcp:8081
大多数情况下,上述这些命令有效,但有时无效。而现在,他们似乎停止了工作。我无法弄清楚这个错误背后的原因。
请指导我摆脱这个错误的永久修复。
我使用的代码是 -
import React, {
Component,
DrawerLayoutAndroid
} from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
Button,
Dimensions
} from 'react-native';
import {
StackNavigator
} from 'react-navigation';
class MainActivity extends Component {
static navigationOptions = {
title: 'MainActivity',
};
FunctionToOpenSecondActivity = () => {
this.props.navigation.navigate('Second');
}
render() {
return ( <
View style = {
styles.MainContainer
} >
<
View style = {
{
marginBottom: 20
}
} >
<
Text style = {
styles.TextStyle
} > This is MainActivity < /Text>
<
/View>
<
Button onPress = {
this.FunctionToOpenSecondActivity
}
title = 'Click here To Open Second Activity' / >
</View>
);
}
}
class SecondActivity extends Component {
static navigationOptions = {
title: 'SecondActivity',
};
render() {
var navigationView = (
<View style = {{flex: 1, backgroundColor: '#fff'}}>
<Text style={{margin: 10, fontSize: 15, textAlign: 'left'}}>I am in the Drawer</Text>
</View>
);
var DrawerLayoutAndroid = require('DrawerLayoutAndroid');
return ( <
View style = {
styles.MainContainer
} >
<DrawerLayoutAndroid
drawerWidth={100}
drawerPosition={DrawerLayoutAndroid.positions.Left}
renderNavigationView={() => navigationView}>
<View style={{flex: 1, alignItems: 'center'}}>
<Text style={{margin: 10, fontSize: 15, textAlign: 'right'}}>Hello</Text>
<Text style={{margin: 10, fontSize: 15, textAlign: 'right'}}>World!</Text>
</View>
</DrawerLayoutAndroid>
<
/View>
);
}
}
export default Project = StackNavigator({
First: {
screen: MainActivity
},
Second: {
screen: SecondActivity
}
});
const styles = StyleSheet.create({
MainContainer: {
justifyContent: 'center',
flex: 1,
margin: 10
},
TextStyle: {
fontSize: 23,
textAlign: 'center',
color: '#000',
},
});
const FirstRoute = () => (
<View style={[styles.container, { backgroundColor: '#ff4081' }]} />
);
const SecondRoute = () => (
<View style={[styles.container, { backgroundColor: '#673ab7' }]} />
);
我曾尝试检查类似的问题,但无法获得任何令人满意的结果。
解决方案
推荐阅读
- c - LibGCC 编译失败并出现错误:无法计算目标文件的后缀:无法编译
- javascript - 如何从另一个 module.exports 文件永久变量
- java - Java spring boot,POJO中的Lombok用于响应实体主体
- javascript - 谷歌地图:打印地图时如何解决问题?
- r - InvBoxCox 在 R 库“预测”中默认为 FALSE
- excel - 如果尚未在工作表中,则将粘贴复制到新工作表中
- node.js - 处理 csv 文件,然后通过电子邮件发送结果
- django - 包含模板中的 Django Rest Framework 表单不会接收数据
- c# - CS0118 没有任何解决方案。“变量像类型一样使用”
- vba - 范围与规格有何不同?