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

Appcelerator JIRA | Ashraf Abu | 1 year ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    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}

    Appcelerator JIRA | 1 year ago | Ashraf Abu
    java.lang.ClassCastException: org.appcelerator.titanium.TiActivity cannot be cast to android.support.v7.app.ActionBarActivity
  2. 0

    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}

    Appcelerator JIRA | 1 year ago | Ashraf Abu
    java.lang.ClassCastException: org.appcelerator.titanium.TiActivity cannot be cast to android.support.v7.app.ActionBarActivity

    Root Cause Analysis

    1. java.lang.ClassCastException

      org.appcelerator.titanium.TiActivity cannot be cast to android.support.v7.app.ActionBarActivity

      at org.appcelerator.titanium.proxy.ActivityProxy.getActionBar()
    2. org.appcelerator.titanium
      ActivityProxy.getActionBar
      1. org.appcelerator.titanium.proxy.ActivityProxy.getActionBar(ActivityProxy.java:255)
      1 frame
    3. org.appcelerator.kroll
      KrollProxy.handleMessage
      1. org.appcelerator.kroll.runtime.v8.V8Object.nativeFireEvent(Native Method)
      2. org.appcelerator.kroll.runtime.v8.V8Object.fireEvent(V8Object.java:62)
      3. org.appcelerator.kroll.KrollProxy.doFireEvent(KrollProxy.java:908)
      4. org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1131)
      4 frames
    4. org.appcelerator.titanium
      TiWindowProxy.handleMessage
      1. org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:349)
      2. org.appcelerator.titanium.proxy.TiWindowProxy.handleMessage(TiWindowProxy.java:102)
      2 frames
    5. ti.modules.titanium
      WindowProxy.handleMessage
      1. ti.modules.titanium.ui.WindowProxy.handleMessage(WindowProxy.java:428)
      1 frame
    6. Android Platform
      Looper.loop
      1. android.os.Handler.dispatchMessage(Handler.java:98)
      2. android.os.Looper.loop(Looper.java:136)
      2 frames
    7. org.appcelerator.kroll
      KrollRuntime$KrollRuntimeThread.run
      1. org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:112)
      1 frame