{ "id": "167572", "key": "TIMOB-24686", "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": [], "resolution": null, "resolutiondate": null, "created": "2017-05-11T12:38:16.000+0000", "priority": null, "labels": [], "versions": [], "issuelinks": [], "assignee": null, "updated": "2018-02-28T19:55:16.000+0000", "status": { "description": "The issue is open and ready for the assignee to start work on it.", "name": "Open", "id": "1", "statusCategory": { "id": 2, "key": "new", "colorName": "blue-gray", "name": "To Do" } }, "components": [], "description": "I have been eventually getting a crash with this exception:\r\n\r\n{code:java}\r\nlang.java.NullPointerException: (Attempt to invoke virtual method 'android.view.Window android.app.Activity.getWindow()' on a null object reference)\r\nat proxy.titanium.appcelerator.org.TiViewProxy.handleMessage(TiViewProxy.java:323)\r\nat proxy.titanium.appcelerator.org.TiWindowProxy.handleMessage(TiWindowProxy.java:116)\r\nat ui.titanium.modules.ti.WindowProxy.handleMessage(WindowProxy.java:453)\r\nat os.android.Handler.dispatchMessage(Handler.java:98)\r\nat os.android.Looper.loop(Looper.java:145)\r\nat app.android.ActivityThread.main(ActivityThread.java:5951)\r\nat reflect.lang.java.Method.invoke(Native Method)\r\nat reflect.lang.java.Method.invoke(Method.java:372)\r\nat os.internal.android.com.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)\r\nat os.internal.android.com.ZygoteInit.main(ZygoteInit.java:1195)\r\n{code}\r\n\r\nI checked [proxy.titanium.appcelerator.org.TiViewProxy's handleMessage method|https://github.com/appcelerator/titanium_mobile/blob/a8aceeaeee02ed9c8ea70c835a0e78960e254a55/android/titanium/src/java/org/appcelerator/titanium/proxy/TiViewProxy.java#L227] and it indeed calls getWindow() on what is returned by TiApplication.getAppCurrentActivity(), on [MSG_GETSIZE|https://github.com/appcelerator/titanium_mobile/blob/a8aceeaeee02ed9c8ea70c835a0e78960e254a55/android/titanium/src/java/org/appcelerator/titanium/proxy/TiViewProxy.java#L296] and on [MSG_GETRECT|https://github.com/appcelerator/titanium_mobile/blob/a8aceeaeee02ed9c8ea70c835a0e78960e254a55/android/titanium/src/java/org/appcelerator/titanium/proxy/TiViewProxy.java#L323]. The [docs|http://docs.appcelerator.com/module-apidoc/latest/android/org/appcelerator/titanium/TiApplication.html] state that TiApplication.getAppCurrentActivity() returns ??the current activity if exists. Otherwise, the thread will wait for a valid activity to be visible.??, but [it does in fact return null|https://github.com/appcelerator/titanium_mobile/blob/11ce8248edb5d821d18e1c3217bf06b99c96d33f/android/titanium/src/java/org/appcelerator/titanium/TiApplication.java#L294] if no Activity is present.", "attachment": [], "flagged": false, "summary": "Calling getWindow() on a null Activity reference", "creator": { "name": "caioiglesias88", "key": "caioiglesias88", "displayName": "Caio Iglesias", "active": true, "timeZone": "Europe/Amsterdam" }, "subtasks": [], "reporter": { "name": "caioiglesias88", "key": "caioiglesias88", "displayName": "Caio Iglesias", "active": true, "timeZone": "Europe/Amsterdam" }, "environment": "Android", "comment": { "comments": [], "maxResults": 0, "total": 0, "startAt": 0 } } }