java.lang.NullPointerException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • java.lang.NullPointerException
    via GitHub by banobi
    ,
  • java.lang.NullPointerException
    via GitHub by banobi
    ,
  • h5. Steps to reproduce: 1. Use the code below in your app.js: {code} var window = Titanium.UI.createWindow(); var button = Ti.UI.createButton( { title: "Close Me", center: {x: "50%", y: "50%"}, }); button.addEventListener("click", function(e) { var activity = Ti.Android.currentActivity; if (!activity) { return; } activity.onDestroy = function(e) { // Crashes when accessing "size" or "rect" property. var size = button.size; var rect = button.rect; }; activity.finish(); }); window.add(button); window.open(); {code} (there can be more properties but I have checked {{size}} & {{rect}} here). 2. Build the app for android device. 3. After the app launches, click on {{Close Me}} button. h5.Actual Result: 1. The app crashes with below java.lang.NullPointerException: {code} [WARN] : W/System.err: java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.Window android.app.Activity.getWindow()' on a null object reference [WARN] : W/System.err: at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:296) [WARN] : W/System.err: at android.os.Handler.dispatchMessage(Handler.java:98) [WARN] : W/System.err: at org.appcelerator.kroll.common.TiMessenger.sendMessage(TiMessenger.java:323) [WARN] : W/System.err: at org.appcelerator.kroll.common.TiMessenger.sendBlockingMessage(TiMessenger.java:289) [WARN] : W/System.err: at org.appcelerator.kroll.common.TiMessenger.sendBlockingMainMessage(TiMessenger.java:164) [WARN] : W/System.err: at org.appcelerator.titanium.proxy.TiViewProxy.getSize(TiViewProxy.java:376) [WARN] : W/System.err: at org.appcelerator.kroll.runtime.v8.V8Object.nativeCallProperty(Native Method) [WARN] : W/System.err: at org.appcelerator.kroll.runtime.v8.V8Object.callProperty(V8Object.java:73) [WARN] : W/System.err: at org.appcelerator.kroll.KrollProxy.callPropertySync(KrollProxy.java:672) [WARN] : W/System.err: at org.appcelerator.titanium.TiBaseActivity.dispatchCallback(TiBaseActivity.java:1194) [WARN] : W/System.err: at org.appcelerator.titanium.TiBaseActivity.onDestroy(TiBaseActivity.java:1525) [WARN] : W/System.err: at org.appcelerator.titanium.TiLaunchActivity.onDestroy(TiLaunchActivity.java:460) [WARN] : W/System.err: at org.appcelerator.titanium.TiRootActivity.onDestroy(TiRootActivity.java:204) [WARN] : W/System.err: at android.app.Activity.performDestroy(Activity.java:6422) [WARN] : W/System.err: at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1142) [WARN] : W/System.err: at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3818) [WARN] : W/System.err: at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3849) [WARN] : W/System.err: at android.app.ActivityThread.-wrap5(ActivityThread.java) [WARN] : W/System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1398) [WARN] : W/System.err: at android.os.Handler.dispatchMessage(Handler.java:102) [WARN] : W/System.err: at android.os.Looper.loop(Looper.java:148) [WARN] : W/System.err: at android.app.ActivityThread.main(ActivityThread.java:5417) [WARN] : W/System.err: at java.lang.reflect.Method.invoke(Native Method) [WARN] : W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) [WARN] : W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) [WARN] : TiExceptionHandler: (main) [2096,2096] Activity is null or already finishing, skipping dialog. [ERROR] : V8Exception: Exception occurred at /app.js:1: Uncaught Attempt to invoke virtual method 'android.view.Window android.app.Activity.getWindow()' on a null object reference [ERROR] : V8Exception: Attempt to invoke virtual method 'android.view.Window android.app.Activity.getWindow()' on a null object reference {code} h5.Actual Results: 1. The app should not crash.
    via by Lokesh Choudhary,
  • java.lang.NullPointerException
    via GitHub by banobi
    ,
  • java.lang.NullPointerException
    via GitHub by banobi
    ,
    • java.lang.NullPointerException at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:268)
    No Bugmate found.