Реагировать на сбой приложения Native при посещении указанного экрана c - PullRequest
0 голосов
/ 24 апреля 2020

Этот экран отлично работает при тестировании с использованием Expo, но вылетает из-за сбоя приложения, когда оно связано с apk

Я не уверен, что вызвало крэ sh, но оно работает на Экспо. Это было протестировано как на эмуляторах, так и на реальных android устройствах с одинаковым поведением.

Это журнал ошибок устройства при посещении экрана:

04-22 10:14:11.713  7008  7008 E unknown:ReactNative: Tried to remove non-existent frame callback
04-22 10:14:11.778  1731  7439 E ResolverController: No valid NAT64 prefix (101, <unspecified>/0)
04-22 10:14:11.786  7008  7065 E GraphResponse: {HttpStatus: 400, errorCode: 100, subErrorCode: 33, errorType: GraphMethodException, errorMessage: Unsupported get request. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api}
04-22 10:14:11.963  7008  7008 E c       : java.lang.RuntimeException: A TaskDescription's primary color should be opaque
04-22 10:14:11.963  7008  7008 E CrashlyticsCore: Crashlytics must be initialized by calling Fabric.with(Context) prior to logging exceptions.
04-22 10:14:12.023  1731  7449 E ResolverController: No valid NAT64 prefix (101, <unspecified>/0

И это это соответствующий экран:

import React, { Component } from 'react'
import { View } from 'react-native'
import MapView from 'react-native-maps'
import { Appbar } from 'react-native-paper'

import Database from './components/Database'
const db = new Database()

import styles from './components/allStyles'

export default class MapScreen extends Component {

  state = {
    emergencies: [],
  };

  componentDidMount() {
    db.mapOn(emergencies => {
        this.setState(previousState => ({
            emergencies: previousState.emergencies.concat(emergencies),
        }))
    })
  }

  render() {
    k = 0
    return (
      <View style={styles.absoluteFillView}>
        <MapView
          style={styles.absoluteFillView}
          mapType={"satellite"}
          showsUserLocation={true}
          region={{
            latitude: 39.625083,
            longitude:  -79.956796,
            latitudeDelta: 0.0025,
            longitudeDelta: 0.0025,
          }}
        >
          {this.state.emergencies.map(emergency => {
            if(k + 1 == this.state.emergencies.length){
              color = 'red';
            }
            else {
              color = 'orange';
            }
            return (
              <MapView.Marker 
                key = {k++}
                title={emergency.title}
                description={emergency.description}
                coordinate={{
                  latitude: emergency.latitude,
                  longitude: emergency.longitude,
                }}
                pinColor={color}
              />
            );
          })}
        </MapView>
        <Appbar.Header
          dark = {true}
          style={{backgroundColor:'#bdbdbd'}}
        >
        <Appbar.Action 
          icon = 'arrow-left'
          size = {24}
            onPress={() =>{
              this.props.navigation.navigate('Home')
            }}
        />
        </Appbar.Header>
      </View>
    );
  }
  componentWillUnmount(){
    db.mapOff()
  }
}

Вот функции прослушивателя событий, используемые в componentDidMount () и componentWillUnmount ():

mapOn = callback => {
    firebase.database().ref('alerts/emergency/').on('child_added', snapshot => {
        callback(this.edit(snapshot))
    })
}

mapOff = () => {
    firebase.database().ref('alerts/emergency/').off()
}

edit = snapshot => {

    const { name, description } = snapshot.val()
    const { longitude, latitude } = snapshot.val().location

    const emergency = { title: name, description, longitude, latitude}

    return emergency
}

Any help into what may be causing the issue would be very helpful.
...