I have been building this react native app and it has run flawlessly on all simulators, both in debug and release mode.
However, as i started testing on devices, only android 7.0 devices experience inconsistent crashes with the app. It does not just crash on startup, sometimes it waits for the images to load before it crashes. Sometimes when i type in a textfield (during login) it crashes.
The biggest issue here is that there are no errors thrown during debug.
I have tried running
adb logcat *:S ReactNative:V ReactNativeJS:V
but no errors are thrown there.
Using
adb logcat *:E
the only error i get is this:
render function of component that contains everything:
render() {
if(!this.state.merchants || this.state.merchants.length == 0)
{
return <View style={{flex: 1,width: '100%', justifyContent:'center', alignItems: 'center', backgroundColor: Colors.themeBackground}}>
<Text style={{fontFamily: 'avenir-medium', width:'60%', color: 'gray', fontSize: 26, textAlign: 'center'}}>
Connection Error. Please check your connection and refresh!
</Text>
</View>
}
return (
<View style={{ backgroundColor: Colors.themeBackground, flex: 1 }}>
<FlatList
data={this.state.merchants}
extraData={this.state.refresh}
renderItem={({ item }) => <MerchantListItem merchant={item} onItemPress={()=>{
this.props.navigation.navigate('merchantDetail',{merchant: item})
}}/>}
keyExtractor={(item) => {
return `${item.id}`
}}
/>
</View>
)
}
and merchant list item:
class MerchantListItem extends React.PureComponent {
constructor(props) {
super(props);
}
render() {
let merchant = this.props.merchant
if(!merchant)
{
return <View/>
}
let name = merchant.name || ''
let address = merchant.address_summary || ''
let price = merchant.price || ''
let id = merchant.id || ''
let image_uri = `${NetworkManager.domain}/GetImageForMerchant/${id}`
// console.log(image_uri)
return <View style={styles.merchantListItemContainerView}>
<TouchableOpacity style={{flex: 1}} onPress={()=>{
if(this.props.onItemPress)
{
this.props.onItemPress()
}
}}>
<View style={{flex: 1, backgroundColor: 'black', alignItems: 'center', justifyContent: 'center'}}>
<Image source={{uri: image_uri}} style={{width: '100%', height: '100%', position: 'absolute', opacity: 0.4}}></Image>
{/* <Image source={require('../../assets/Images/DiscountImages/0.jpg')} style={{flex: 1, position: 'absolute', opacity: 0.5}}/> */}
<View style={{flex: 1, position: 'absolute'}}>
<Text style={styles.merchantListItemText}>
{name}
</Text>
<Text style={styles.merchantListItemSubText}>
{address}
</Text>
<Text style={styles.merchantListItemSubText}>
{price}
</Text>
</View>
</View>
</TouchableOpacity>
</View>
}
}