Javascript 在发布模式下对本机应用程序崩溃作出反应?
我的应用程序在发布模式下崩溃,但在调试模式下工作正常。此问题是由于平台检查引起的 实际上,如果没有Javascript 在发布模式下对本机应用程序崩溃作出反应?,javascript,reactjs,react-native,Javascript,Reactjs,React Native,我的应用程序在发布模式下崩溃,但在调试模式下工作正常。此问题是由于平台检查引起的 实际上,如果没有平台检查代码,应用程序运行正常 这些是我正在执行动画的键盘事件 _keyboardDidShow = e => { keyboardHeight = e.endCoordinates.height, height = Platform.OS == "ios" ? keyboardHeight : 0 Animated.timing(this.state.bottomPadding, {
平台
检查代码,应用程序运行正常
这些是我正在执行动画的键盘
事件
_keyboardDidShow = e => {
keyboardHeight = e.endCoordinates.height,
height = Platform.OS == "ios" ? keyboardHeight : 0
Animated.timing(this.state.bottomPadding, {
toValue: 0,
duration: 150
}).start();
Animated.timing(this.state.keyboardHeight, {
toValue: height,
duration: 150,
}).start();
this.setState({ isFocused: true });
}
_keyboardDidHide = () => {
this.setState({ isFocused: false });
Animated.timing(this.state.bottomPadding, {
toValue: 0,
duration: 150
}).start();
Animated.timing(this.state.keyboardHeight, {
toValue: 0,
duration: 0
}).start();
}
这是我正在制作动画的部分代码
customFocusNavigator = () => {
return (
<Animated.View
style={[styles.FocusNavigator,{ bottom: this.state.keyboardHeight }]}
>
<View style={styles.FocusNavigatorDirectionBox}>
<TouchableOpacity
onPress={() => {
this.state.index > 0
? this["customtext" + (this.state.index - 1)].changeFocus()
: this["customtext0"].changeFocus();
}}
style={[
styles.bottomSubView,
{ borderRightColor: constant.COLOR.WHITE, borderRightWidth: 1 }
]}
>
<Text style={styles.FocusNavigatorText}>Previous</Text>
</TouchableOpacity>
<TouchableOpacity
onPress={() => {
this.state.index < 4
? this["customtext" + (this.state.index + 1)].changeFocus()
: this["customtext0"].changeFocus();
}}
style={styles.bottomSubView}
>
<Text style={styles.FocusNavigatorText}>Next</Text>
</TouchableOpacity>
</View>
<TouchableOpacity
onPress={() => {
Keyboard.dismiss();
}}
>
<Text style={[styles.FocusNavigatorText, { fontWeight: "bold" }]}>
Done
</Text>
</TouchableOpacity>
</Animated.View>
);
};
如果我给出的是硬编码值,假设在
KeyboardDidShow
中高度为300,则应用程序没有崩溃,但在添加Platform
后,在释放模式下检查开始崩溃。我需要平台特定高度,因此需要检查平台。是否有错误日志?如果是,请在您的问题上分享。对不起,我没有发布模式的错误日志。@TanvirSingh,那么您需要获取这些错误日志。这是解决问题的第一步。您可以生成一个发布版本(对于Android,您可以遵循),然后可以使用adb
进行安装。完成以上操作后,在终端/命令提示符窗口中启动adb logcat,查看应用程序崩溃时抛出的错误。我认为这行中的错误是“keyboardHeight=e.endCoordinates.height”。删除“,”或添加“;”而不是“,”@VishalJadav不,即使
keyboardHeight: new Animated.Value(0),