{"action":"closed","issue":{"url":"https://api.github.com/repos/FokkeZB/nl.fokkezb.drawer/issues/54","labels_url":"https://api.github.com/repos/FokkeZB/nl.fokkezb.drawer/issues/54/labels{/name}","comments_url":"https://api.github.com/repos/FokkeZB/nl.fokkezb.drawer/issues/54/comments","events_url":"https://api.github.com/repos/FokkeZB/nl.fokkezb.drawer/issues/54/events","html_url":"https://github.com/FokkeZB/nl.fokkezb.drawer/issues/54","id":99776942,"number":54,"title":"Runtime error on Android","user":{"login":"ManadayM","id":521134,"avatar_url":"https://avatars.githubusercontent.com/u/521134?v=3","gravatar_id":"","url":"https://api.github.com/users/ManadayM","html_url":"https://github.com/ManadayM","followers_url":"https://api.github.com/users/ManadayM/followers","following_url":"https://api.github.com/users/ManadayM/following{/other_user}","gists_url":"https://api.github.com/users/ManadayM/gists{/gist_id}","starred_url":"https://api.github.com/users/ManadayM/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ManadayM/subscriptions","organizations_url":"https://api.github.com/users/ManadayM/orgs","repos_url":"https://api.github.com/users/ManadayM/repos","events_url":"https://api.github.com/users/ManadayM/events{/privacy}","received_events_url":"https://api.github.com/users/ManadayM/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-08-08T06:09:32Z","updated_at":"2015-08-14T10:49:33Z","closed_at":"2015-08-14T10:49:33Z","body":"Hi Fokke,\r\n\r\nI want to use this module in my next app and hence I was trying it out on a simple app. It worked fine on iOS but not on Android. It throws following error on very first run on Android device. Seems like I'm missing or doing something wrong. Could you please help me to solve this?\r\n\r\n**Runtime Error**\r\n```\r\n[ERROR] :  TiExceptionHandler: (main) [486,486] ----- Titanium Javascript Runtime Error -----\r\n[ERROR] :  TiExceptionHandler: (main) [0,486] - In alloy/widgets/nl.fokkezb.drawer/controllers/widget.js:84,28\r\n[ERROR] :  TiExceptionHandler: (main) [0,486] - Message: Uncaught Error: Attempt to invoke virtual method 'java.lang.Object java.lang.ref.WeakReference.get()' on a null object reference\r\n[ERROR] :  TiExceptionHandler: (main) [0,486] - Source:             if ($.instance.isLeftWindowOpen()) return $.instance.toggleLeftWin\r\n[ERROR] :  V8Exception: Exception occurred at alloy/widgets/nl.fokkezb.drawer/controllers/widget.js:84: Uncaught Error: Attempt to invoke virtual method 'java.lang.Object java.lang.ref.WeakReference.get()' on a null object reference\r\n```\r\n\r\n**Platform details**\r\n1. Titanium SDK 3.5.1.GA\r\n2. CLI 4.0.1\r\n3. ti.alloy 1.6.2\r\n4. Targeting Android SDK: 21 (Moto E, Android 5.1)\r\n\r\n**Code in my app**\r\n\r\n**index.xml**\r\n```\r\n<Alloy>\r\n\t<Widget id=\"drawer\" src=\"nl.fokkezb.drawer\">\r\n\t\t<Window module=\"xp.ui\" role=\"leftWindow\">\r\n\t\t\t<Require id=\"menu\" src=\"menu\" />\r\n\t\t</Window>\r\n\r\n\t\t<Window platform=\"ios\" role=\"centerWindow\">\r\n\t\t\t<View id=\"container\" class=\"container\" />\r\n\t\t</Window>\r\n\r\n\t\t<View platform=\"android\" role=\"centerWindow\">\r\n\t\t\t<View id=\"container\" class=\"container\" />\r\n\t\t</View>\r\n\t</Widget>\r\n</Alloy>\r\n```\r\n\r\n**index.tss**\r\n```\r\n\"#drawer[platform=android]\": {\r\n\topenDrawerGestureMode: \"OPEN_MODE_MARGIN\",\r\n\tcloseDrawerGestureMode: \"CLOSE_MODE_MARGIN\",\r\n\tanimationMode: \"ANIMATION_NONE\",\r\n\tdrawerLayout: false\r\n}\r\n\r\n\".container\":{\r\n\twidth: Ti.UI.FILL,\r\n\theight: Ti.UI.FILL,\r\n\tbackgroundColor: '#fff'\r\n}\r\n```\r\n\r\n**index.js**\r\n```\r\nvar curIndex = -1;\r\nvar sections = Alloy.CFG.sections;\r\n\r\nfunction loadSection(e) {\r\n\r\n\tif (curIndex == e.index) return;\r\n\r\n\tvar views = $.container.getChildren() || [];\r\n\r\n\tvar pageController = Alloy.createController(sections[e.index].controller);\r\n\r\n\tif (views.length == 0)/* While container has no subviews*/\r\n\t{\r\n\t\t$.container.add(pageController.getView());\r\n\r\n\t} else/* Remove all previously added views, before adding new section */\r\n\t{\r\n\t\tviews[0].cleanUp && views[0].cleanUp();\r\n\t\t$.container.remove(views[0]);\r\n\t\tviews.length = 0;\r\n\t\tviews = null;\r\n\r\n\t\t// add new section to the root view\r\n\t\t$.container.add(pageController.getView());\r\n\t}\r\n\r\n\tcurIndex = e.index;\r\n\t\t\r\n\t// **If I comment out the following line of code then app works fine! **\r\n\t$.drawer.closeLeftWindow();\r\n}\r\n\r\nTi.App.addEventListener('loadSection', loadSection);\r\n\r\n// load initial section\r\nloadSection({\r\n\tindex : 0\r\n});\r\n\r\n$.drawer.open();\r\n```"}}