{ "id": "153563", "key": "TIMOB-20089", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "16997", "name": "Release 5.2.0", "archived": false, "released": true, "releaseDate": "2016-02-23" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2015-12-03T02:58:59.000+0000", "created": "2015-12-02T11:36:19.000+0000", "priority": { "name": "Critical", "id": "1" }, "labels": [ "View", "android", "crash", "layout" ], "versions": [], "issuelinks": [], "assignee": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "updated": "2016-01-21T01:55:53.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "When setting a view's layout to \"null\", the app completely crashes:\r\n\r\n{code}\r\n[ERROR] TiApplication: (main) [396,396] Sending event: exception on thread: main msg:java.lang.RuntimeException: Unable to start activity ComponentInfo{com.jolicode.testview/org.appcelerator.titanium.TiActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference; Titanium 5.0.2,2015/09/30 12:07,92c2265\r\n[ERROR] TiApplication: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.jolicode.testview/org.appcelerator.titanium.TiActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference\r\n[ERROR] TiApplication: \tat android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)\r\n[ERROR] TiApplication: \tat android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)\r\n[ERROR] TiApplication: \tat android.app.ActivityThread.access$800(ActivityThread.java:151)\r\n[ERROR] TiApplication: \tat android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)\r\n[ERROR] TiApplication: \tat android.os.Handler.dispatchMessage(Handler.java:102)\r\n[ERROR] TiApplication: \tat android.os.Looper.loop(Looper.java:135)\r\n[ERROR] TiApplication: \tat android.app.ActivityThread.main(ActivityThread.java:5254)\r\n[ERROR] TiApplication: \tat java.lang.reflect.Method.invoke(Native Method)\r\n[ERROR] TiApplication: \tat java.lang.reflect.Method.invoke(Method.java:372)\r\n[ERROR] TiApplication: \tat com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)\r\n[ERROR] TiApplication: \tat com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)\r\n[ERROR] TiApplication: Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference\r\n[ERROR] TiApplication: \tat ti.modules.titanium.ui.widget.TiView.(TiView.java:25)\r\n[ERROR] TiApplication: \tat ti.modules.titanium.ui.ViewProxy.createView(ViewProxy.java:33)\r\n[ERROR] TiApplication: \tat org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:485)\r\n[ERROR] TiApplication: \tat org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:471)\r\n[ERROR] TiApplication: \tat org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:509)\r\n[ERROR] TiApplication: \tat org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:493)\r\n[ERROR] TiApplication: \tat org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:471)\r\n[ERROR] TiApplication: \tat org.appcelerator.titanium.proxy.TiViewProxy.handleAdd(TiViewProxy.java:672)\r\n[ERROR] TiApplication: \tat org.appcelerator.titanium.proxy.TiViewProxy.add(TiViewProxy.java:566)\r\n[ERROR] TiApplication: \tat ti.modules.titanium.ui.WindowProxy.windowCreated(WindowProxy.java:237)\r\n[ERROR] TiApplication: \tat org.appcelerator.titanium.TiActivityWindows.windowCreated(TiActivityWindows.java:33)\r\n[ERROR] TiApplication: \tat org.appcelerator.titanium.TiBaseActivity.windowCreated(TiBaseActivity.java:458)\r\n[ERROR] TiApplication: \tat org.appcelerator.titanium.TiBaseActivity.onCreate(TiBaseActivity.java:551)\r\n[ERROR] TiApplication: \tat org.appcelerator.titanium.TiActivity.onCreate(TiActivity.java:18)\r\n[ERROR] TiApplication: \tat android.app.Activity.performCreate(Activity.java:5990)\r\n[ERROR] TiApplication: \tat android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)\r\n[ERROR] TiApplication: \tat android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)\r\n[ERROR] TiApplication: \t... 10 more\r\n{code}\r\n\r\nSteps to reproduce:\r\n\r\n * create a new Alloy application\r\n * app/controllers/index.js : \r\n{code}\r\n$.index.open();\r\n{code}\r\n * app/views/index.xml : \r\n{code}\r\n\r\n \r\n\t\r\n \r\n \r\n \r\n\r\n{code}\r\n * app/styles/index.tss : \r\n{code}\r\n'.horizontal': {\r\n layout: 'horizontal'\r\n}\r\n\r\n'.oh-shit': {\r\n layout: null\r\n}\r\n{code}\r\n * compile and run the app, it crashes at startup on android\r\n\r\nReason: The [TiView class constructor|https://github.com/appcelerator/titanium_mobile/blob/bc85170157d3bebc5de1d61a9fe6e34bce84a8c9/android/modules/ui/src/java/ti/modules/titanium/ui/widget/TiView.java#L23] does not correctly check that the layout property is not null, and it crashes on line 25 when calling {{equals()}}.\r\n\r\nExpected behavior: The app should not crash and the view should have the default layout ({{LayoutArrangement.DEFAULT}})", "attachment": [], "flagged": false, "summary": "Android: setting a view layout to null crashes the app", "creator": { "name": "xavier", "key": "xavier", "displayName": "Xavier Lacot", "active": true, "timeZone": "Europe/Paris" }, "subtasks": [], "reporter": { "name": "xavier", "key": "xavier", "displayName": "Xavier Lacot", "active": true, "timeZone": "Europe/Paris" }, "environment": "android, titanium_mobile latest master version", "closedSprints": [ { "id": 529, "state": "closed", "name": "2015 Sprint 24 SDK", "startDate": "2015-11-21T01:30:12.670Z", "endDate": "2015-12-05T01:30:00.000Z", "completeDate": "2015-12-07T03:57:17.094Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "371909", "author": { "name": "xavier", "key": "xavier", "displayName": "Xavier Lacot", "active": true, "timeZone": "Europe/Paris" }, "body": "A pull request to fix this problem has been submitted in https://github.com/appcelerator/titanium_mobile/pull/7529", "updateAuthor": { "name": "xavier", "key": "xavier", "displayName": "Xavier Lacot", "active": true, "timeZone": "Europe/Paris" }, "created": "2015-12-02T12:16:06.000+0000", "updated": "2015-12-02T12:16:06.000+0000" }, { "id": "371916", "author": { "name": "timpoulsen", "key": "timpoulsen", "displayName": "Tim Poulsen", "active": true, "timeZone": "America/Havana" }, "body": "I'm curious (but obviously too lazy to test) whether setting layout to {{undefined}} rather than {{null}} also causes the crash. This is how I generally handle resetting properties to their default / unset states. I hope Appc will merge your PR.", "updateAuthor": { "name": "timpoulsen", "key": "timpoulsen", "displayName": "Tim Poulsen", "active": true, "timeZone": "America/Havana" }, "created": "2015-12-02T14:07:25.000+0000", "updated": "2015-12-02T14:07:25.000+0000" }, { "id": "371996", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "Classic App.js test code:-\r\n{code:javascript}\r\nvar win = Ti.UI.createWindow();\r\n \r\nvar view = Ti.UI.createView({\r\n\tlayout: null\r\n});\r\n \r\nwin.add(view);\r\nwin.open();\r\n{code}", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2015-12-03T02:55:53.000+0000", "updated": "2015-12-03T02:55:53.000+0000" }, { "id": "371998", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "PR https://github.com/appcelerator/titanium_mobile/pull/7529 reviewed and merged.\r\n", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2015-12-03T02:59:20.000+0000", "updated": "2015-12-03T02:59:20.000+0000" }, { "id": "375024", "author": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Verified the fix.\r\n\r\nSetting the layout property of the view to null does not crash the app/\r\n\r\nClosing.\r\n\r\nEnvironment:\r\nAppc Studio : 4.5.0.201601131150\r\nTi SDK : 5.2.0.v20160114021251\r\nTi CLI : 5.0.5\r\nAlloy : 1.7.26\r\nMAC Yosemite : 10.10.5\r\nAppc NPM : 4.2.3-1\r\nAppc CLI : 5.2.0-231\r\nNode: v0.12.27\r\nNexus 6P - Android 6.0 ", "updateAuthor": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2016-01-21T00:52:32.000+0000", "updated": "2016-01-21T00:52:32.000+0000" } ], "maxResults": 5, "total": 5, "startAt": 0 } } }