{"action":"created","issue":{"url":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-ReactNative/issues/14","repository_url":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-ReactNative","labels_url":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-ReactNative/issues/14/labels{/name}","comments_url":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-ReactNative/issues/14/comments","events_url":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-ReactNative/issues/14/events","html_url":"https://github.com/forcedotcom/SalesforceMobileSDK-ReactNative/issues/14","id":197044813,"number":14,"title":"Null object reference with react-native switch","user":{"login":"mkoo21","id":12832801,"avatar_url":"https://avatars.githubusercontent.com/u/12832801?v=3","gravatar_id":"","url":"https://api.github.com/users/mkoo21","html_url":"https://github.com/mkoo21","followers_url":"https://api.github.com/users/mkoo21/followers","following_url":"https://api.github.com/users/mkoo21/following{/other_user}","gists_url":"https://api.github.com/users/mkoo21/gists{/gist_id}","starred_url":"https://api.github.com/users/mkoo21/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mkoo21/subscriptions","organizations_url":"https://api.github.com/users/mkoo21/orgs","repos_url":"https://api.github.com/users/mkoo21/repos","events_url":"https://api.github.com/users/mkoo21/events{/privacy}","received_events_url":"https://api.github.com/users/mkoo21/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-12-21T22:08:53Z","updated_at":"2016-12-23T19:17:36Z","closed_at":null,"body":"We are trying to upgrade our react-native app from mobile SDK version 4.3 to 5.0, but we are getting a strange issue with react-native's switch component. We are testing on android 6, and we get the error on both the emulator and physical device.\r\n\r\nTo reproduce: Add a switch component anywhere in a new forcedroid project, or just use my index.android.js:\r\n\r\n```\r\n'use strict';\r\n\r\nimport React from 'react';\r\nimport {\r\n    AppRegistry,\r\n    StyleSheet,\r\n    Text,\r\n    View,\r\n    ListView,\r\n    PixelRatio,\r\n    Navigator,\r\n    Switch\r\n} from 'react-native';\r\n\r\nimport {oauth, net} from 'react-native-force';\r\n\r\nvar App = React.createClass({\r\n    getInitialState: function() {\r\n        return {\r\n            authenticated: false,\r\n            value: true\r\n        };\r\n    },\r\n\r\n    componentDidMount: function() {\r\n        var that = this;\r\n        oauth.authenticate(\r\n            function() {\r\n                that.setState({authenticated:true});\r\n            },\r\n            function(error) {\r\n                console.log('Failed to authenticate:' + error);\r\n            }\r\n        );\r\n    },\r\n\r\n    render: function() {\r\n        if (!this.state.authenticated)\r\n            return (<View/>); // Show splash screen if you have one\r\n\r\n        return (<Navigator\r\n                  style={styles.container}\r\n                  initialRoute={{name: 'Mobile SDK Sample App', index: 0}}\r\n                  renderScene={(route, navigator) => (<UserList/>)}\r\n                  navigationBar={<Navigator.NavigationBar routeMapper={NavigationBarRouteMapper} />} />);\r\n    }\r\n});\r\n\r\n\r\nvar NavigationBarRouteMapper = {\r\n\r\n  LeftButton: function(route, navigator, index, navState) {\r\n      return null;\r\n  },\r\n\r\n  RightButton: function(route, navigator, index, navState) {\r\n      return null;\r\n  },\r\n\r\n  Title: function(route, navigator, index, navState) {\r\n      return (\r\n              <View style={styles.navBar}>\r\n                <Text style={styles.navBarText}>\r\n                  {route.name}\r\n                </Text>\r\n              </View>\r\n      );\r\n  },\r\n};\r\n\r\n\r\nvar UserList = React.createClass({\r\n    getInitialState: function() {\r\n      var ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});\r\n      return {\r\n          dataSource: ds.cloneWithRows([]),\r\n      };\r\n    },\r\n    \r\n    componentDidMount: function() {\r\n        var that = this;\r\n        var soql = 'SELECT Id, Name FROM User LIMIT 10';\r\n        net.query(soql,\r\n                  function(response) {\r\n                      var users = response.records;\r\n                      var data = [];\r\n                      for (var i in users) {\r\n                          data.push(users[i][\"Name\"]);\r\n                      }\r\n\r\n                      that.setState({\r\n                          dataSource: that.getDataSource(data),\r\n                      });\r\n\r\n                  });\r\n    },\r\n\r\n    getDataSource: function(users: Array<any>): ListViewDataSource {\r\n        return this.state.dataSource.cloneWithRows(users);\r\n    },\r\n\r\n    render: function() {\r\n        return (\r\n            <ListView style={styles.scene}\r\n              dataSource={this.state.dataSource}\r\n              renderRow={this.renderRow}\r\n              enableEmptySections={true}\r\n            />\r\n      );\r\n    },\r\n\r\n    renderRow: function(rowData: Object) {\r\n        return (\r\n                <View>\r\n                    <View style={styles.row}>\r\n                      <Text numberOfLines={1}>\r\n                       {rowData}\r\n                      </Text>\r\n                    </View>\r\n                    <Switch value={this.state.value} onChange={ (newVal) => this.setState({ value: newVal })} />\r\n                    <View style={styles.cellBorder} />\r\n                </View>\r\n        );\r\n    }\r\n});\r\n\r\nvar styles = StyleSheet.create({\r\n    container: {\r\n        backgroundColor: 'white',\r\n    },\r\n    navBar: {\r\n        height: 50,\r\n        flexDirection: 'row',\r\n        alignItems: 'center',\r\n    },\r\n    navBarText: {\r\n        fontSize: 18,\r\n    },\r\n    scene: {\r\n        flex: 1,\r\n        paddingTop: 50,\r\n    },\r\n    row: {\r\n        flex: 1,\r\n        alignItems: 'center',\r\n        backgroundColor: 'white',\r\n        flexDirection: 'row',\r\n        padding: 12,\r\n    },\r\n    cellBorder: {\r\n        backgroundColor: 'rgba(0, 0, 0, 0.1)',\r\n        // Trick to get the thinest line the device can display\r\n        height: 1 / PixelRatio.get(),\r\n        marginLeft: 4,\r\n    },\r\n});\r\n\r\nAppRegistry.registerComponent('switchtest', () => App);\r\n```\r\n\r\nExpected behaviour: Render a switch in each row\r\n\r\nActual behaviour: \r\n![screen shot 2016-12-21 at 4 55 43 pm](https://cloud.githubusercontent.com/assets/12832801/21407663/b89d2392-c79e-11e6-9324-620bc96478cc.png)\r\n\r\nError Log: \r\n```\r\n12-21 17:02:04.106  2455  2489 E unknown:React: Exception in native call\r\n12-21 17:02:04.106  2455  2489 E unknown:React: java.lang.NullPointerException: Attempt to invoke interface method 'int java.lang.CharSequence.length()' on a null object reference\r\n12-21 17:02:04.106  2455  2489 E unknown:React: \tat android.text.StaticLayout.<init>(StaticLayout.java:420)\r\n12-21 17:02:04.106  2455  2489 E unknown:React: \tat android.support.v7.widget.SwitchCompat.makeLayout(SwitchCompat.java:606)\r\n12-21 17:02:04.106  2455  2489 E unknown:React: \tat android.support.v7.widget.SwitchCompat.onMeasure(SwitchCompat.java:526)\r\n12-21 17:02:04.106  2455  2489 E unknown:React: \tat android.view.View.measure(View.java:18788)\r\n12-21 17:02:04.106  2455  2489 E unknown:React: \tat com.facebook.react.views.switchview.ReactSwitchManager$ReactSwitchShadowNode.measure(ReactSwitchManager.java:62)\r\n12-21 17:02:04.106  2455  2489 E unknown:React: \tat com.facebook.csslayout.CSSNode.measure(CSSNode.java:147)\r\n12-21 17:02:04.106  2455  2489 E unknown:React: \tat com.facebook.csslayout.LayoutEngine.layoutNodeImpl(LayoutEngine.java:563)\r\n12-21 17:02:04.106  2455  2489 E unknown:React: \tat com.facebook.csslayout.LayoutEngine.layoutNodeInternal(LayoutEngine.java:405)\r\n12-21 17:02:04.106  2455  2489 E unknown:React: \tat com.facebook.csslayout.LayoutEngine.layoutNodeImpl(LayoutEngine.java:756)\r\n12-21 17:02:04.106  2455  2489 E unknown:React: \tat com.facebook.csslayout.LayoutEngine.layoutNodeInternal(LayoutEngine.java:405)\r\n12-21 17:02:04.106  2455  2489 E unknown:React: \tat com.facebook.csslayout.LayoutEngine.layoutNodeImpl(LayoutEngine.java:756)\r\n12-21 17:02:04.106  2455  2489 E unknown:React: \tat com.facebook.csslayout.LayoutEngine.layoutNodeInternal(LayoutEngine.java:405)\r\n12-21 17:02:04.106  2455  2489 E unknown:React: \tat com.facebook.csslayout.LayoutEngine.layoutNodeImpl(LayoutEngine.java:756)\r\n12-21 17:02:04.106  2455  2489 E unknown:React: \tat com.facebook.csslayout.LayoutEngine.layoutNodeInternal(LayoutEngine.java:405)\r\n12-21 17:02:04.106  2455  2489 E unknown:React: \tat com.facebook.csslayout.LayoutEngine.layoutNodeImpl(LayoutEngine.java:1156)\r\n12-21 17:02:04.106  2455  2489 E unknown:React: \tat com.facebook.csslayout.LayoutEngine.layoutNodeInternal(LayoutEngine.java:405)\r\n12-21 17:02:04.106  2455  2489 E unknown:React: \tat com.facebook.csslayout.LayoutEngine.layoutNodeImpl(LayoutEngine.java:1344)\r\n12-21 17:02:04.106  2455  2489 E unknown:React: \tat com.facebook.csslayout.LayoutEngine.layoutNodeInternal(LayoutEngine.java:405)\r\n12-21 17:02:04.106  2455  2489 E unknown:React: \tat com.facebook.csslayout.LayoutEngine.layoutNodeImpl(LayoutEngine.java:1156)\r\n12-21 17:02:04.106  2455  2489 E unknown:React: \tat com.facebook.csslayout.LayoutEngine.layoutNodeInternal(LayoutEngine.java:405)\r\n12-21 17:02:04.106  2455  2489 E unknown:React: \tat com.facebook.csslayout.LayoutEngine.layoutNodeImpl(LayoutEngine.java:1156)\r\n12-21 17:02:04.106  2455  2489 E unknown:React: \tat com.facebook.csslayout.LayoutEngine.layoutNodeInternal(LayoutEngine.java:405)\r\n12-21 17:02:04.106  2455  2489 E unknown:React: \tat com.facebook.csslayout.LayoutEngine.layoutNodeImpl(LayoutEngine.java:1156)\r\n12-21 17:02:04.106  2455  2489 E unknown:React: \tat com.facebook.csslayout.LayoutEngine.layoutNodeInternal(LayoutEngine.java:405)\r\n12-21 17:02:04.106  2455  2489 E unknown:React: \tat com.facebook.csslayout.LayoutEngine.layoutNodeImpl(LayoutEngine.java:1156)\r\n12-21 17:02:04.106  2455  2489 E unknown:React: \tat com.facebook.csslayout.LayoutEngine.layoutNodeInternal(LayoutEngine.java:405)\r\n12-21 17:02:04.106  2455  2489 E unknown:React: \tat com.facebook.csslayout.LayoutEngine.layoutNode(LayoutEngine.java:237)\r\n12-21 17:02:04.106  2455  2489 E unknown:React: \tat com.facebook.csslayout.CSSNode.calculateLayout(CSSNode.java:156)\r\n12-21 17:02:04.106  2455  2489 E unknown:React: \tat com.facebook.react.uimanager.UIImplementation.calculateRootLayout(UIImplementation.java:756)\r\n12-21 17:02:04.106  2455  2489 E unknown:React: \tat com.facebook.react.uimanager.UIImplementation.updateViewHierarchy(UIImplementation.java:530)\r\n12-21 17:02:04.106  2455  2489 E unknown:React: \tat com.facebook.react.uimanager.UIImplementation.dispatchViewUpdates(UIImplementation.java:519)\r\n12-21 17:02:04.106  2455  2489 E unknown:React: \tat com.facebook.react.uimanager.UIManagerModule.onBatchComplete(UIManagerModule.java:499)\r\n12-21 17:02:04.106  2455  2489 E unknown:React: \tat com.facebook.react.cxxbridge.NativeModuleRegistry.onBatchComplete(NativeModuleRegistry.java:92)\r\n12-21 17:02:04.106  2455  2489 E unknown:React: \tat com.facebook.react.cxxbridge.CatalystInstanceImpl$BridgeCallback.onBatchComplete(CatalystInstanceImpl.java:129)\r\n12-21 17:02:04.106  2455  2489 E unknown:React: \tat com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)\r\n12-21 17:02:04.106  2455  2489 E unknown:React: \tat android.os.Handler.handleCallback(Handler.java:739)\r\n12-21 17:02:04.106  2455  2489 E unknown:React: \tat android.os.Handler.dispatchMessage(Handler.java:95)\r\n12-21 17:02:04.106  2455  2489 E unknown:React: \tat com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)\r\n12-21 17:02:04.106  2455  2489 E unknown:React: \tat android.os.Looper.loop(Looper.java:148)\r\n12-21 17:02:04.106  2455  2489 E unknown:React: \tat com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:196)\r\n12-21 17:02:04.106  2455  2489 E unknown:React: \tat java.lang.Thread.run(Thread.java:818)\r\n12-21 17:02:04.117  2455  2489 E unknown:React: Exception in native call\r\n12-21 17:02:04.117  2455  2489 E unknown:React: java.lang.NullPointerException: Attempt to invoke interface method 'int java.lang.CharSequence.length()' on a null object reference\r\n12-21 17:02:04.117  2455  2489 E unknown:React: \tat android.text.StaticLayout.<init>(StaticLayout.java:420)\r\n12-21 17:02:04.117  2455  2489 E unknown:React: \tat android.support.v7.widget.SwitchCompat.makeLayout(SwitchCompat.java:606)\r\n12-21 17:02:04.117  2455  2489 E unknown:React: \tat android.support.v7.widget.SwitchCompat.onMeasure(SwitchCompat.java:526)\r\n12-21 17:02:04.117  2455  2489 E unknown:React: \tat android.view.View.measure(View.java:18788)\r\n12-21 17:02:04.117  2455  2489 E unknown:React: \tat com.facebook.react.views.switchview.ReactSwitchManager$ReactSwitchShadowNode.measure(ReactSwitchManager.java:62)\r\n12-21 17:02:04.117  2455  2489 E unknown:React: \tat com.facebook.csslayout.CSSNode.measure(CSSNode.java:147)\r\n12-21 17:02:04.117  2455  2489 E unknown:React: \tat com.facebook.csslayout.LayoutEngine.layoutNodeImpl(LayoutEngine.java:563)\r\n12-21 17:02:04.117  2455  2489 E unknown:React: \tat com.facebook.csslayout.LayoutEngine.layoutNodeInternal(LayoutEngine.java:405)\r\n12-21 17:02:04.117  2455  2489 E unknown:React: \tat com.facebook.csslayout.LayoutEngine.layoutNodeImpl(LayoutEngine.java:756)\r\n12-21 17:02:04.117  2455  2489 E unknown:React: \tat com.facebook.csslayout.LayoutEngine.layoutNodeInternal(LayoutEngine.java:405)\r\n12-21 17:02:04.117  2455  2489 E unknown:React: \tat com.facebook.csslayout.LayoutEngine.layoutNodeImpl(LayoutEngine.java:756)\r\n12-21 17:02:04.117  2455  2489 E unknown:React: \tat com.facebook.csslayout.LayoutEngine.layoutNodeInternal(LayoutEngine.java:405)\r\n12-21 17:02:04.117  2455  2489 E unknown:React: \tat com.facebook.csslayout.LayoutEngine.layoutNodeImpl(LayoutEngine.java:756)\r\n12-21 17:02:04.117  2455  2489 E unknown:React: \tat com.facebook.csslayout.LayoutEngine.layoutNodeInternal(LayoutEngine.java:405)\r\n12-21 17:02:04.117  2455  2489 E unknown:React: \tat com.facebook.csslayout.LayoutEngine.layoutNodeImpl(LayoutEngine.java:1156)\r\n12-21 17:02:04.117  2455  2489 E unknown:React: \tat com.facebook.csslayout.LayoutEngine.layoutNodeInternal(LayoutEngine.java:405)\r\n12-21 17:02:04.117  2455  2489 E unknown:React: \tat com.facebook.csslayout.LayoutEngine.layoutNodeImpl(LayoutEngine.java:1344)\r\n12-21 17:02:04.117  2455  2489 E unknown:React: \tat com.facebook.csslayout.LayoutEngine.layoutNodeInternal(LayoutEngine.java:405)\r\n12-21 17:02:04.117  2455  2489 E unknown:React: \tat com.facebook.csslayout.LayoutEngine.layoutNodeImpl(LayoutEngine.java:1156)\r\n12-21 17:02:04.117  2455  2489 E unknown:React: \tat com.facebook.csslayout.LayoutEngine.layoutNodeInternal(LayoutEngine.java:405)\r\n12-21 17:02:04.117  2455  2489 E unknown:React: \tat com.facebook.csslayout.LayoutEngine.layoutNodeImpl(LayoutEngine.java:1156)\r\n12-21 17:02:04.117  2455  2489 E unknown:React: \tat com.facebook.csslayout.LayoutEngine.layoutNodeInternal(LayoutEngine.java:405)\r\n12-21 17:02:04.117  2455  2489 E unknown:React: \tat com.facebook.csslayout.LayoutEngine.layoutNodeImpl(LayoutEngine.java:1156)\r\n12-21 17:02:04.117  2455  2489 E unknown:React: \tat com.facebook.csslayout.LayoutEngine.layoutNodeInternal(LayoutEngine.java:405)\r\n12-21 17:02:04.117  2455  2489 E unknown:React: \tat com.facebook.csslayout.LayoutEngine.layoutNodeImpl(LayoutEngine.java:1156)\r\n12-21 17:02:04.117  2455  2489 E unknown:React: \tat com.facebook.csslayout.LayoutEngine.layoutNodeInternal(LayoutEngine.java:405)\r\n12-21 17:02:04.117  2455  2489 E unknown:React: \tat com.facebook.csslayout.LayoutEngine.layoutNode(LayoutEngine.java:237)\r\n12-21 17:02:04.117  2455  2489 E unknown:React: \tat com.facebook.csslayout.CSSNode.calculateLayout(CSSNode.java:156)\r\n12-21 17:02:04.117  2455  2489 E unknown:React: \tat com.facebook.react.uimanager.UIImplementation.calculateRootLayout(UIImplementation.java:756)\r\n12-21 17:02:04.117  2455  2489 E unknown:React: \tat com.facebook.react.uimanager.UIImplementation.updateViewHierarchy(UIImplementation.java:530)\r\n12-21 17:02:04.117  2455  2489 E unknown:React: \tat com.facebook.react.uimanager.UIImplementation.dispatchViewUpdates(UIImplementation.java:519)\r\n12-21 17:02:04.117  2455  2489 E unknown:React: \tat com.facebook.react.uimanager.UIManagerModule.onBatchComplete(UIManagerModule.java:499)\r\n12-21 17:02:04.117  2455  2489 E unknown:React: \tat com.facebook.react.cxxbridge.NativeModuleRegistry.onBatchComplete(NativeModuleRegistry.java:92)\r\n12-21 17:02:04.117  2455  2489 E unknown:React: \tat com.facebook.react.cxxbridge.CatalystInstanceImpl$BridgeCallback.onBatchComplete(CatalystInstanceImpl.java:129)\r\n12-21 17:02:04.117  2455  2489 E unknown:React: \tat com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)\r\n12-21 17:02:04.117  2455  2489 E unknown:React: \tat android.os.Handler.handleCallback(Handler.java:739)\r\n12-21 17:02:04.117  2455  2489 E unknown:React: \tat android.os.Handler.dispatchMessage(Handler.java:95)\r\n12-21 17:02:04.117  2455  2489 E unknown:React: \tat com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)\r\n12-21 17:02:04.117  2455  2489 E unknown:React: \tat android.os.Looper.loop(Looper.java:148)\r\n12-21 17:02:04.117  2455  2489 E unknown:React: \tat com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:196)\r\n12-21 17:02:04.117  2455  2489 E unknown:React: \tat java.lang.Thread.run(Thread.java:818)\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-ReactNative/issues/comments/269033972","html_url":"https://github.com/forcedotcom/SalesforceMobileSDK-ReactNative/issues/14#issuecomment-269033972","issue_url":"https://api.github.com/repos/forcedotcom/SalesforceMobileSDK-ReactNative/issues/14","id":269033972,"user":{"login":"mkoo21","id":12832801,"avatar_url":"https://avatars.githubusercontent.com/u/12832801?v=3","gravatar_id":"","url":"https://api.github.com/users/mkoo21","html_url":"https://github.com/mkoo21","followers_url":"https://api.github.com/users/mkoo21/followers","following_url":"https://api.github.com/users/mkoo21/following{/other_user}","gists_url":"https://api.github.com/users/mkoo21/gists{/gist_id}","starred_url":"https://api.github.com/users/mkoo21/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mkoo21/subscriptions","organizations_url":"https://api.github.com/users/mkoo21/orgs","repos_url":"https://api.github.com/users/mkoo21/repos","events_url":"https://api.github.com/users/mkoo21/events{/privacy}","received_events_url":"https://api.github.com/users/mkoo21/received_events","type":"User","site_admin":false},"created_at":"2016-12-23T19:17:36Z","updated_at":"2016-12-23T19:17:36Z","body":"For what it's worth, we are able to get around the issue by using react-native init with react 15.3.2 and RN 0.35 and manually linking the salesforce react libraries. Our container also works nicely with code push's automatic linker while forcedroid does not, so manually linking with a react-native init project is probably the better way to go for android for now"}}
{"actor":{"display_login":"mkoo21"}}