【发布时间】:2019-07-06 18:24:31
【问题描述】:
我正在编辑其中一个“.js”文件,在进行一些更改后保存我的工作后,当我在模拟器上键入“rr”以刷新应用程序时,我不断收到此消息。
Android 应用程序模拟器不断停止 应用信息 关闭应用
在 Visual Studio 代码编辑器中创建 Form.js 并在我的项目中的组件文件夹下并将其导入我的 Login.js 后,错误开始出现发生。 IDK 我做错了什么。我是 React Native 的新手,正在学习。
Form.js
import React, {Component} from 'react';
import {
StyleSheet,
Text,
View,
TextInput
} from 'react-native';
export default class Login extends Component<{}> {
render(){
return(
<View style={styles.container}>
<TextInput style={styles.inputBox}
underlineColorAndroid='rgba(0,0,0,0)'
placeholder="Email"
placeholderTextColor = "#ffffff"
/>
<TextInput style={styles.inputBox}
underlineColorAndroid='rgba(0,0,0,0)'
placeholder="Password"
placeholderTextColor = "#ffffff"
/>
</View>
)
}
}
const styles = StyleSheet.create({
container : {
flex: 1,
justifyContent: 'center',
alignItems: 'center'
},
inputBox: {
width:300,
backgroundColor:'rgba(255,255,255,0.3)',
borderRadius: 25,
paddingHorizontal: 16,
fontSize: 16,
color:'#ffffff',
marginVertical: '10'
}
});
Login.js
import React, {Component} from 'react';
import {
StyleSheet,
Text,
View,
StatusBar
} from 'react-native';
import Logo from '../components/Logo';
import Form from '../components/Form';
export default class Login extends Component<{}> {
render () {
return(
<View style={styles.container}>
<Logo/>
<Form/>
</View>
)
}
}
const styles = StyleSheet.create({
container : {
backgroundColor: '#29b6f6',
flex: 1,
alignItems: 'center',
justifyContent: 'center',
}
});
【问题讨论】:
-
这是因为您对代码的最后更改。不知何故,它使您的应用程序崩溃。只是停止节点。回滚您的更改。然后再次点击命令
react-native run-android -
感谢您回复@ParasKorat。我回滚了我的更改,通过退出和关闭命令行来停止节点,重新打开命令行,cd 到正确的目录文件夹,然后运行 [react-native run-android] 命令。我仍然遇到同样的错误。
-
很抱歉给您带来不便。试试这个,从模拟器中卸载应用程序,先用这个命令“cd android”然后“.\gradlew clean”清理你的android gradle。并再次运行。
-
@ParasKorat,我跟着你的步骤。这是我按顺序执行的操作: 1. 单击“应用程序信息”,然后单击“卸载”。 2.然后我关闭了节点cli,然后关闭了我的命令提示符。 3. 我重新打开命令提示符并 cd 到 (C:\Users\Clint\Desktop\DesktopTings\Reactnative\lulock>cd android) 然后运行 [gradlew clean]。 4.打开一个模拟器。 5. cd 回到根项目和 [react-native run-android]。仍然得到错误。我编辑了我的帖子,详细显示了我对哪些文件所做的更改导致应用程序崩溃。
-
试试我在下面写的这个答案
标签: android react-native mobile-application