java.lang.ClassCastException: org.appcelerator.titanium.TiActivity cannot be cast to android.support.v7.app.ActionBarActivity

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.

  • Regression in Master branch using this code: https://jira.appcelerator.org/browse/TIMOB-16619 Actionbar is not available as the activities are no longer extending ActionBarActivity. Instead, they are AppCompatActivity. {code} var win = Ti.UI.createWindow({ title: "Old Title", navBarHidden: false }); var actionBar; win.addEventListener("open", function() { if (Ti.Platform.osname === "android") { if (! win.activity) { Ti.API.error("Can't access action bar on a lightweight window."); } else { actionBar = win.activity.actionBar; if (actionBar) { actionBar.backgroundImage = "/bg.png"; actionBar.title = "New Title"; actionBar.onHomeIconItemSelected = function() { Ti.API.info("Home icon clicked!"); }; } } } }); win.open(); {code} {code} [WARN] : W/System.err: java.lang.ClassCastException: org.appcelerator.titanium.TiActivity cannot be cast to android.support.v7.app.ActionBarActivity [WARN] : W/System.err: at org.appcelerator.titanium.proxy.ActivityProxy.getActionBar(ActivityProxy.java:255) [WARN] : W/System.err: at org.appcelerator.kroll.runtime.v8.V8Object.nativeFireEvent(Native Method) [WARN] : W/System.err: at org.appcelerator.kroll.runtime.v8.V8Object.fireEvent(V8Object.java:62) [WARN] : W/System.err: at org.appcelerator.kroll.KrollProxy.doFireEvent(KrollProxy.java:908) [WARN] : W/System.err: at org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1131) [WARN] : W/System.err: at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:349) [WARN] : W/System.err: at org.appcelerator.titanium.proxy.TiWindowProxy.handleMessage(TiWindowProxy.java:102) [WARN] : W/System.err: at ti.modules.titanium.ui.WindowProxy.handleMessage(WindowProxy.java:428) [WARN] : W/System.err: at android.os.Handler.dispatchMessage(Handler.java:98) [WARN] : W/System.err: at android.os.Looper.loop(Looper.java:136) [WARN] : W/System.err: at org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:112) [ERROR] : TiExceptionHandler: (main) [286,286] ----- Titanium Javascript Runtime Error ----- [ERROR] : TiExceptionHandler: (main) [0,286] - In app.js:12,37 [ERROR] : TiExceptionHandler: (main) [1,287] - Message: Uncaught Error: org.appcelerator.titanium.TiActivity cannot be cast to android.support.v7.app.ActionBarActivity [ERROR] : TiExceptionHandler: (main) [1,288] - Source: actionBar = win.activity.actionBar; [ERROR] : V8Exception: Exception occurred at app.js:12: Uncaught Error: org.appcelerator.titanium.TiActivity cannot be cast to android.support.v7.app.ActionBarActivity {code}
    via by Ashraf Abu,
  • Regression in Master branch using this code: https://jira.appcelerator.org/browse/TIMOB-16619 Actionbar is not available as the activities are no longer extending ActionBarActivity. Instead, they are AppCompatActivity. {code} var win = Ti.UI.createWindow({ title: "Old Title", navBarHidden: false }); var actionBar; win.addEventListener("open", function() { if (Ti.Platform.osname === "android") { if (! win.activity) { Ti.API.error("Can't access action bar on a lightweight window."); } else { actionBar = win.activity.actionBar; if (actionBar) { actionBar.backgroundImage = "/bg.png"; actionBar.title = "New Title"; actionBar.onHomeIconItemSelected = function() { Ti.API.info("Home icon clicked!"); }; } } } }); win.open(); {code} {code} [WARN] : W/System.err: java.lang.ClassCastException: org.appcelerator.titanium.TiActivity cannot be cast to android.support.v7.app.ActionBarActivity [WARN] : W/System.err: at org.appcelerator.titanium.proxy.ActivityProxy.getActionBar(ActivityProxy.java:255) [WARN] : W/System.err: at org.appcelerator.kroll.runtime.v8.V8Object.nativeFireEvent(Native Method) [WARN] : W/System.err: at org.appcelerator.kroll.runtime.v8.V8Object.fireEvent(V8Object.java:62) [WARN] : W/System.err: at org.appcelerator.kroll.KrollProxy.doFireEvent(KrollProxy.java:908) [WARN] : W/System.err: at org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1131) [WARN] : W/System.err: at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:349) [WARN] : W/System.err: at org.appcelerator.titanium.proxy.TiWindowProxy.handleMessage(TiWindowProxy.java:102) [WARN] : W/System.err: at ti.modules.titanium.ui.WindowProxy.handleMessage(WindowProxy.java:428) [WARN] : W/System.err: at android.os.Handler.dispatchMessage(Handler.java:98) [WARN] : W/System.err: at android.os.Looper.loop(Looper.java:136) [WARN] : W/System.err: at org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:112) [ERROR] : TiExceptionHandler: (main) [286,286] ----- Titanium Javascript Runtime Error ----- [ERROR] : TiExceptionHandler: (main) [0,286] - In app.js:12,37 [ERROR] : TiExceptionHandler: (main) [1,287] - Message: Uncaught Error: org.appcelerator.titanium.TiActivity cannot be cast to android.support.v7.app.ActionBarActivity [ERROR] : TiExceptionHandler: (main) [1,288] - Source: actionBar = win.activity.actionBar; [ERROR] : V8Exception: Exception occurred at app.js:12: Uncaught Error: org.appcelerator.titanium.TiActivity cannot be cast to android.support.v7.app.ActionBarActivity {code}
    via by Ashraf Abu,
    • java.lang.ClassCastException: org.appcelerator.titanium.TiActivity cannot be cast to android.support.v7.app.ActionBarActivity at org.appcelerator.titanium.proxy.ActivityProxy.getActionBar(ActivityProxy.java:255) at org.appcelerator.kroll.runtime.v8.V8Object.nativeFireEvent(Native Method) at org.appcelerator.kroll.runtime.v8.V8Object.fireEvent(V8Object.java:62) at org.appcelerator.kroll.KrollProxy.doFireEvent(KrollProxy.java:908) at org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1131) at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:349) at org.appcelerator.titanium.proxy.TiWindowProxy.handleMessage(TiWindowProxy.java:102) at ti.modules.titanium.ui.WindowProxy.handleMessage(WindowProxy.java:428) at android.os.Handler.dispatchMessage(Handler.java:98) at android.os.Looper.loop(Looper.java:136) at org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:112)
    No Bugmate found.