Сбой приложения при сборке релиза с ошибкой undefined не является объектом (оценка 'e.default') - PullRequest
0 голосов
/ 16 января 2019

Мое приложение падает в режиме выпуска, но работает нормально в режиме отладки. Эта проблема вызвана проверкой Platform.

На самом деле приложение работает нормально без этого Platform контрольного кода.

Это Keyboard события, над которыми я выполняю анимацию.

_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>
  );
 };

Отдых в состоянии

 keyboardHeight: new Animated.Value(0),

Если я даю жестко запрограммированное значение, предположим 300 вместо высоты в KeyboardDidShow, приложение не падает, но после добавления Platform проверьте запуск сбоя в режиме выпуска. Мне нужна конкретная высота платформы, поэтому необходимо проверить Platform.

Ниже приводится отчет logcat:

[Info] 01-15 19:39:41.902 11958 11999 E ReactNativeJS: TypeError: undefined is not an object (evaluating 'e.default')
01-15 19:39:41.902 11958 11999 E ReactNativeJS: 
01-15 19:39:41.902 11958 11999 E ReactNativeJS: This error is located at:
01-15 19:39:41.902 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.902 11958 11999 E ReactNativeJS:     in inject-t-with-profileStore-store
01-15 19:39:41.902 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.902 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.902 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.902 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.902 11958 11999 E ReactNativeJS:     in n
01-15 19:39:41.902 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.902 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.902 11958 11999 E ReactNativeJS:     in n
01-15 19:39:41.902 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.902 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.902 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.902 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.902 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.902 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.902 11958 11999 E ReactNativeJS:     in n
01-15 19:39:41.902 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.902 11958 11999 E ReactNativeJS:     in n
01-15 19:39:41.902 11958 11999 E ReactNativeJS:     in u
01-15 19:39:41.902 11958 11999 E ReactNativeJS:     in e
01-15 19:39:41.902 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.902 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.902 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.902 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.902 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.902 11958 11999 E ReactNativeJS:     in Unknown
01-15 19:39:41.902 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.902 11958 11999 E ReactNativeJS:     in n
01-15 19:39:41.904 11958 11999 E ReactNativeJS: TypeError: TypeError: undefined is not an object (evaluating 'e.default')
01-15 19:39:41.904 11958 11999 E ReactNativeJS: 
01-15 19:39:41.904 11958 11999 E ReactNativeJS: This error is located at:
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in inject-t-with-profileStore-store
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in n
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in n
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in n
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in n
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in u
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in e
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in Unknown
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in n
01-15 19:39:41.904 11958 11999 E ReactNativeJS: 
01-15 19:39:41.904 11958 11999 E ReactNativeJS: This error is located at:
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in e
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in Unknown
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in n
01-15 19:39:41.904 11958 11999 E ReactNativeJS: TypeError: TypeError: undefined is not an object (evaluating 'e.default')
01-15 19:39:41.904 11958 11999 E ReactNativeJS: 
01-15 19:39:41.904 11958 11999 E ReactNativeJS: This error is located at:
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in inject-t-with-profileStore-store
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in n
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in n
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in n
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in n
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in u
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in e
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in Unknown
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in n
01-15 19:39:41.904 11958 11999 E ReactNativeJS: 
01-15 19:39:41.904 11958 11999 E ReactNativeJS: This error is located at:
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in e
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in Unknown
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in n
[Info] 01-15 19:39:41.943 11958 11958 D ReactNative: ReactInstanceManager.detachViewFromInstance()
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...