使用React Native App

时间:2017-03-25 22:58:53

标签: reactjs react-native react-redux

我有一个本机应用程序,它使用来自Web服务的信息。我在几个小时后第一次加载应用时出现错误,Chrome控制台中没有显示任何内容。该应用程序崩溃,下次它的工作fina。我在互联网上找不到任何有用的信息。这就是logcat告诉我的内容

03-26 11:23:37.219 24853 24887 I ReactNativeJS: Running application "attendees" with appParams: {"initialProps":{},"rootTag":1}. __DEV__ === true, development-level warning are ON, performance optimizations are OFF
03-26 11:23:37.392 24853 24853 V BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@fe3592d
03-26 11:23:37.393 24853 24853 V BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@ec6de62
03-26 11:23:37.408 24853 24888 W unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.text.ReactVirtualTextShadowNode
03-26 11:23:37.476 24853 24853 V BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@958b7dc
03-26 11:23:37.579 24853 24887 I ReactNativeJS: action @ 11:23:37.576 SET_DEVICE_CONNECTION
03-26 11:23:37.582 24853 24887 I ReactNativeJS: '%c prev state', 'color: #9E9E9E; font-weight: bold', { listAllPublicEvents: [],
03-26 11:23:37.582 24853 24887 I ReactNativeJS:   setCurrentEvent: {},
03-26 11:23:37.582 24853 24887 I ReactNativeJS:   setCurrentEventRow: -1,
03-26 11:23:37.582 24853 24887 I ReactNativeJS:   setDeviceConnection: true }
03-26 11:23:37.582 24853 24887 I ReactNativeJS: '%c action', 'color: #03A9F4; font-weight: bold', { type: 'SET_DEVICE_CONNECTION', isConnected: true }
03-26 11:23:37.583 24853 24887 I ReactNativeJS: '%c next state', 'color: #4CAF50; font-weight: bold', { listAllPublicEvents: [],
03-26 11:23:37.583 24853 24887 I ReactNativeJS:   setCurrentEvent: {},
03-26 11:23:37.583 24853 24887 I ReactNativeJS:   setCurrentEventRow: -1,
03-26 11:23:37.583 24853 24887 I ReactNativeJS:   setDeviceConnection: true }
03-26 11:23:37.583 24853 24887 I ReactNativeJS: —— log end ——
03-26 11:23:38.067 24853 24858 I art     : Do partial code cache collection, code=24KB, data=30KB
03-26 11:23:38.068 24853 24858 I art     : After code cache collection, code=24KB, data=30KB
03-26 11:23:38.068 24853 24858 I art     : Increasing code cache capacity to 128KB
03-26 11:23:38.124 24853 24887 F libc    : Fatal signal 11 (SIGSEGV), code 2, fault addr 0xcdb800cc in tid 24887 (mqt_js)
03-26 11:23:38.125   464   464 W         : debuggerd: handling request: pid=24853 uid=10239 gid=10239 tid=24887
03-26 11:23:38.212 24900 24900 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
03-26 11:23:38.212 24900 24900 F DEBUG   : Build fingerprint: 'OnePlus/OnePlus3/OnePlus3T:7.0/NRD90M/01122128:user/release-keys'
03-26 11:23:38.212 24900 24900 F DEBUG   : Revision: '0'
03-26 11:23:38.212 24900 24900 F DEBUG   : ABI: 'arm'
03-26 11:23:38.213 24900 24900 F DEBUG   : pid: 24853, tid: 24887, name: mqt_js  >>> com.attendees <<<
03-26 11:23:38.213 24900 24900 F DEBUG   : signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0xcdb800cc
03-26 11:23:38.213 24900 24900 F DEBUG   :     r0 cdc35980  r1 0000001a  r2 0000001c  r3 fffffffe
03-26 11:23:38.213 24900 24900 F DEBUG   :     r4 cdb7ffe8  r5 d35669e0  r6 cdb7ffec  r7 d317c348
03-26 11:23:38.213 24900 24900 F DEBUG   :     r8 cdedb755  r9 e6ce6fd1  sl d317c300  fp d317d7d4
03-26 11:23:38.213 24900 24900 F DEBUG   :     ip 0000001f  sp d317c280  lr d3495907  pc e1c5a006  cpsr 800d0030
03-26 11:23:38.214 24900 24900 F DEBUG   : 
03-26 11:23:38.214 24900 24900 F DEBUG   : backtrace:
03-26 11:23:38.214 24900 24900 F DEBUG   :     #00 pc 00000006  <anonymous:e1c5a000>
03-26 11:23:38.214 24900 24900 F DEBUG   :     #01 pc 000fe903  /data/app/com.attendees-1/lib/arm/libjsc.so
03-26 11:23:38.214 24900 24900 F DEBUG   :     #02 pc fffffff9  <unknown>
03-26 11:23:38.593  2798  3358 V AlarmManager: Triggering alarm #0: Alarm{b9ac566 type 3 when 67906618 com.google.android.gms}operation =Intent { act=com.google.android.gms.location.fused.SEND_LOCATION_IN_SMD_MODE pkg=com.google.android.gms }
03-26 11:23:38.616  4380 18478 W ctxmgr  : [AclManager]No 2 for (accnt=account#-1827342116#, com.google.android.gms(10010):UserLocationProducer, vrsn=10298000, 0, 3pPkg = null ,  3pMdlId = null). Was: 2 for 1, account#-1827342116#
03-26 11:23:38.623  4380  6960 W ctxmgr  : [AclManager]No 2 for (accnt=account#-480821402#, com.google.android.gms(10010):UserLocationProducer, vrsn=10298000, 0, 3pPkg = null ,  3pMdlId = null). Was: 2 for 1, account#-480821402#
03-26 11:23:38.862  2798  2835 D DeviceIdleController: handleMessage(6)
03-26 11:23:38.862  2798  2835 D DeviceIdleController: checkTempAppWhitelistTimeout: uid=10010, timeNow=67906887
03-26 11:23:38.862  2798  2835 D DeviceIdleController: Removing UID 10010 from temp whitelist
03-26 11:23:38.862  2798  2835 D DeviceIdleController: Setting wakelock temp whitelist to [10070]
03-26 11:23:38.980  2798 24902 W ActivityManager:   Force finishing activity com.attendees/.MainActivity
03-26 11:23:38.982   464   464 W         : debuggerd: resuming target 24853
03-26 11:23:38.976 24904 24904 W coredump.sh: type=1400 audit(0.0:1421): avc: denied { use } for path="pipe:[933531]" dev="pipefs" ino=933531 scontext=u:r:core_dump:s0 tcontext=u:r:kernel:s0 tclass=fd permissive=0
03-26 11:23:38.976 24904 24904 W coredump.sh: type=1400 audit(0.0:1422): avc: denied { use } for path="/system/bin/linker64" dev="dm-0" ino=608 scontext=u:r:core_dump:s0 tcontext=u:r:kernel:s0 tclass=fd permissive=0
03-26 11:23:38.984  2798 24902 D ActivityTrigger: ActivityTrigger activityPauseTrigger 
03-26 11:23:38.985 24904 24904 F libc    : CANNOT LINK EXECUTABLE "/system/bin/sh": can't enable GNU RELRO protection for "": Permission denied
03-26 11:23:38.994   579   579 E lowmemorykiller: Error writing /proc/24853/oom_score_adj; errno=22
03-26 11:23:39.002  2798 24903 D DropBoxManagerService: file :: /data/system/dropbox/data_app_native_crash@2017-03-26-11_23_38_991.txt
03-26 11:23:39.032  2798  3361 W InputDispatcher: channel '812ef24 com.attendees/com.attendees.MainActivity (server)' ~ Consumer closed input channel or an error occurred.  events=0x9
03-26 11:23:39.032  2798  3361 E InputDispatcher: channel '812ef24 com.attendees/com.attendees.MainActivity (server)' ~ hannel is unrecoverably broken and will be disposedC!
03-26 11:23:39.060  2798  4456 D GraphicsStats: Buffer count: 18
03-26 11:23:39.060  2798  5983 I WindowManager: WIN DEATH: Window{812ef24 u0 com.attendees/com.attendees.MainActivity}
03-26 11:23:39.061  2798  5983 W InputDispatcher: Attempted to unregister already unregistered input channel '812ef24 com.attendees/com.attendees.MainActivity (server)'
03-26 11:23:39.062  2798  5983 I WindowManager: Destroying surface Surface(name=com.attendees/com.attendees.MainActivity) called by com.android.server.wm.WindowStateAnimator.destroySurface:2063 com.android.server.wm.WindowStateAnimator.destroySurfaceLocked:925 com.android.server.wm.WindowState.removeLocked:1465 com.android.server.wm.WindowManagerService.removeWindowInnerLocked:2567 com.android.server.wm.WindowManagerService.removeWindowLocked:2525 com.android.server.wm.WindowState$DeathRecipient.binderDied:1796 android.os.BinderProxy.sendDeathNotice:724 <bottom of call stack> 
03-26 11:23:39.062  2798  5986 I ActivityManager: Process com.attendees (pid 24853) has died
03-26 11:23:39.062  2798  5986 D ActivityManager: cleanUpApplicationRecord -- 24853
03-26 11:23:39.087  4717  4717 D Launcher: updateAutoAdvanceState autoAdvanceRunning = false, mAutoAdvanceRunning = false
03-26 11:23:39.087  4717  4717 D RecyclerViewWrapper: onWindowVisibilityChanged:4
03-26 11:23:39.092  4717  4717 D Launcher: onStart
03-26 11:23:39.092  4717  4717 D Launcher: onResume
03-26 11:23:39.095  4717 24906 D AppTracker: App Event: start
03-26 11:23:39.104  4717  4717 D Launcher: updateAutoAdvanceState autoAdvanceRunning = false, mAutoAdvanceRunning = false
03-26 11:23:39.104  4717  4717 D RecyclerViewWrapper: onWindowVisibilityChanged:0
03-26 11:23:39.139  4717  4717 D Launcher.Folder: [RAINN-3245][getItemCount]Office has 3
03-26 11:23:39.661  4717  5029 W OpenGLRenderer: Incorrectly called buildLayer on View: ShortcutAndWidgetContainer, destroying layer...
03-26 11:23:40.339  2798  2835 D DeviceIdleController: handleMessage(6)
03-26 11:23:40.340  2798  2835 D DeviceIdleController: checkTempAppWhitelistTimeout: uid=10070, timeNow=67908365
03-26 11:23:40.340  2798  2835 D DeviceIdleController: Removing UID 10070 from temp whitelist
03-26 11:23:40.340  2798  2835 D DeviceIdleController: Setting wakelock temp whitelist to []
03-26 11:23:40.990  3536  3764 D NetworkController.MobileSignalController(1): onSignalStrengthsChanged signalStrength=SignalStrength: 99 0 -120 -160 -120 -1 -1 31 -81 -12 202 2147483647 2147483647 4 4 gsm|lte level=4 voicelevel=4 datalevel=4
03-26 11:23:41.003  3536  3764 I NetworkController.MobileSignalController(1):  isDataDisabled:false
03-26 11:23:41.539  2798  2798 I DeviceIdleController: updateChargingLocked: charging=true
03-26 11:23:41.539  2798  2798 I DeviceIdleController: becomeActiveLocked, reason = charging
03-26 11:23:41.543  4411  4521 W QCNEJ   : |CORE| CNE received unexpected action: android.intent.action.BATTERY_CHANGED
03-26 11:23:41.546 23281 23366 D HeadsetStateMachine: Disconnected process message: 10, size: 0
03-26 11:23:41.546 23281 23366 D HeadsetStateMachine: Enter processIntentBatteryChanged()
03-26 11:23:41.546 23281 23366 D HeadsetStateMachine: Exit processIntentBatteryChanged()
03-26 11:23:41.546 23281 23366 D HeadsetStateMachine: Exit Disconnected processMessage() 
03-26 11:23:41.548  4878  4878 D AbstractProcessor: onBatteryChange Percent:32 State:2 
03-26 11:23:41.551  3536  3536 I BatteryController:  fireBatteryLevelChanged mLevel:32 mPluggedIn:true mCharging:true mFastcharge:false
03-26 11:23:41.961  2798  2798 V NotificationService: pkg=com.facebook.orca canInterrupt=false intercept=true
03-26 11:23:41.972  3536  3536 I StatusBarIconView: set mSlot:com.facebook.orca/0x4e21 icon.visible:true mBlocked:false
03-26 11:23:41.980  2798  2798 V NotificationService: pkg=com.facebook.orca canInterrupt=false intercept=true
03-26 11:23:42.016  3536  3536 D PhoneStatusBar: updateMediaMetaData: hasArtwork = true
03-26 11:23:42.016  3536  3536 D StatusBar: onNotificationPosted: end
03-26 11:23:42.016  3536  3536 D PhoneStatusBar: setSystemUiVisibility vis=8 mask=ffffffff oldVal=608 newVal=8 diff=600
03-26 11:23:42.036  3536  3536 D PhoneStatusBar: updateMediaMetaData: hasArtwork = true
03-26 11:23:42.036  3536  3536 D StatusBar: onNotificationPosted: end
03-26 11:23:42.068  3536  3536 D PhoneStatusBar: setSystemUiVisibility vis=608 mask=ffffffff oldVal=8 newVal=608 diff=600
03-26 11:23:42.073  2798  4456 W InputMethodManagerService: Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@67412bd attribute=null, token = android.os.BinderProxy@b368a88
03-26 11:23:42.266  2798  2798 V NotificationService: pkg=com.facebook.orca canInterrupt=false intercept=true
03-26 11:23:42.273  3536  3536 I StatusBarIconView: set mSlot:com.facebook.orca/0x2710 icon.visible:true mBlocked:false
03-26 11:23:42.335  3536  3536 D PhoneStatusBar: updateMediaMetaData: hasArtwork = true
03-26 11:23:42.335  3536  3536 D StatusBar: onNotificationPosted: end
03-26 11:23:42.863 30729 30729 E msgr.ThreadViewFragment: thread wasn't set before fragment was attached to activity!
03-26 11:23:42.887 30729 30729 V BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@450e9a6
03-26 11:23:42.887 30729 30729 V BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@a083fe7
03-26 11:23:42.887 30729 30729 V BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@ca5c794
03-26 11:23:42.887 30729 30729 V BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@5dd423d
03-26 11:23:43.552  3536  3764 D NetworkController.MobileSignalController(1): onSignalStrengthsChanged signalStrength=SignalStrength: 99 0 -120 -160 -120 -1 -1 29 -81 -6 218 2147483647 2147483647 4 4 gsm|lte level=4 voicelevel=4 datalevel=4
03-26 11:23:43.563  3536  3764 I NetworkController.MobileSignalController(1):  isDataDisabled:false
03-26 11:23:44.028  5030 24905 W PlatformStatsUtil: Could not retrieve Usage & Diagnostics setting. Giving up.

这是我的React组件

/**
 * Index iOS - Peewah EMS Attendees
 * @author csacanam
 */

import React, { Component } from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  Image,
  ScrollView,
  ListView,
  View,
  TouchableOpacity,
  NetInfo,
  Platform,
} from 'react-native';
import {
  getTheme,
} from 'react-native-material-kit';
import {
  Actions,
} from 'react-native-router-flux';
import { connect } from 'react-redux';
import moment from 'moment';
import EventHeader from '../components/EventHeader';
import * as Progress from 'react-native-progress';

const theme = getTheme();
const styles = require('../styles');

class AllEvents extends Component {

  constructor(props) {
    super(props);
  }

  componentDidMount() {

    if(Platform.OS === 'ios') {
      NetInfo.isConnected.addEventListener('change', this._handleFirstConnectivityChange); 
    }
    else {
        NetInfo.isConnected.fetch().then(isConnected => {
          if(isConnected) {
              this.props.setDeviceConnection(true);
              this.props.listAllEvents();
          } else {
            this.props.setDeviceConnection(false);
          }
        });
    }

  }

    componentWillUnmount() {
      NetInfo.removeEventListener('change', this._handleConnectionInfoChange);
  }

  _handleFirstConnectivityChange = (isConnected) => {
      if (isConnected) {
        this.props.setDeviceConnection(true);
        this.props.listAllEvents();
      } else {
        this.props.setDeviceConnection(false);
      }
      NetInfo.isConnected.removeEventListener('change', this._handleFirstConnectivityChange);
  }

  render () {

    if(this.props.allEvents.length > 0) {
        return   (<ListView
                      rowHasChanged={this._rowHasChanged}
                      dataSource = {this.props.allEventsListView}
                      renderRow = { (row, sectionId, rowId) => 
                      <View style={[theme.cardStyle, {marginTop: rowId == 0 ? 0:10}]}>
                        <TouchableOpacity
                          onPress = { () => {
                            this.props.setCurrentEvent(row);
                            this.props.setCurrentEventRow(rowId);
                            Actions.eventDetail();
                          }}>
                          <EventHeader event={row} row={rowId}/>
                          <View style={{ padding : 15}}>
                            <Text style={[customStyles.container, {color: row.fontColor} ]}>{row.name}</Text>
                            <Text style={[theme.cardContentStyle, {padding:0}]}>
                              {row.place}{"\n"}{moment(row.startDate).format('ll')}
                            </Text>
                          </View>
                        </TouchableOpacity>
                      </View>}/>);      
    }
    else if ( !this.props.isDeviceConnected ) {
      return (<View style={customStyles.centerView}><Text style={customStyles.noInternetConnectionTitle}>No tienes conexión a Internet</Text></View>);
    }
    else {
      return (<View style={customStyles.centerView}><Progress.Circle size={30} indeterminate={true} /></View>);
    }

  }

}

var customStyles = StyleSheet.create({
  container: {
    color: 'white',
    fontSize: 18,
    fontWeight: 'bold'
  },
  centerView: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center'
  },
  noInternetConnectionTitle: {
  fontWeight: 'bold',
  fontSize: 18,
}
});



function mapStateToProps( state ) {
  return {
    allEvents: state.listAllPublicEvents,
    allEventsListView: ds.cloneWithRows(state.listAllPublicEvents),
    isDeviceConnected: state.setDeviceConnection,
  }
}

const ds = new ListView.DataSource({
  rowHasChanged: (r1, r2) => r1 !== r2
});



AppRegistry.registerComponent('AllEvents', () => AllEvents);

export default connect(mapStateToProps)(AllEvents);

1 个答案:

答案 0 :(得分:0)

经过很多天,我发现这是一个与我用来在获取Web服务之前显示进度条的库相关的泄漏内存错误。是这个图书馆(https://github.com/oblador/react-native-progress)。现在我正在使用这个(https://github.com/bgryszko/react-native-circular-progress),一切正常。