2

I have created an app and it was running successfully till yesterday, by today when I tried running it on my device it shows the following error in logcat and my app gets crashed.

03-31 12:37:47.059: ERROR/(1916): java.lang.ClassCastException: android.widget.ImageView
03-31 12:37:47.239: ERROR/AndroidRuntime(1916): Uncaught handler: thread main exiting due to uncaught exception
03-31 12:37:47.246: ERROR/AndroidRuntime(1916): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.fis.flash/com.fis.flash.FirstImage}: java.lang.ClassCastException: android.widget.AbsoluteLayout
03-31 12:37:47.246: ERROR/AndroidRuntime(1916):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
03-31 12:37:47.246: ERROR/AndroidRuntime(1916):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
03-31 12:37:47.246: ERROR/AndroidRuntime(1916):     at android.app.ActivityThread.access$2200(ActivityThread.java:119)
03-31 12:37:47.246: ERROR/AndroidRuntime(1916):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
03-31 12:37:47.246: ERROR/AndroidRuntime(1916):     at android.os.Handler.dispatchMessage(Handler.java:99)
03-31 12:37:47.246: ERROR/AndroidRuntime(1916):     at android.os.Looper.loop(Looper.java:123)
03-31 12:37:47.246: ERROR/AndroidRuntime(1916):     at android.app.ActivityThread.main(ActivityThread.java:4363)
03-31 12:37:47.246: ERROR/AndroidRuntime(1916):     at java.lang.reflect.Method.invokeNative(Native Method)
03-31 12:37:47.246: ERROR/AndroidRuntime(1916):     at java.lang.reflect.Method.invoke(Method.java:521)
03-31 12:37:47.246: ERROR/AndroidRuntime(1916):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
03-31 12:37:47.246: ERROR/AndroidRuntime(1916):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
03-31 12:37:47.246: ERROR/AndroidRuntime(1916):     at dalvik.system.NativeStart.main(Native Method)
03-31 12:37:47.246: ERROR/AndroidRuntime(1916): Caused by: java.lang.ClassCastException: android.widget.AbsoluteLayout
03-31 12:37:47.246: ERROR/AndroidRuntime(1916):     at com.fis.flash.FirstImage.onCreate(FirstImage.java:106)
03-31 12:37:47.246: ERROR/AndroidRuntime(1916):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-31 12:37:47.246: ERROR/AndroidRuntime(1916):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
03-31 12:37:47.246: ERROR/AndroidRuntime(1916):     ... 11 more

It shows an error in a ImageView of my main class activity, but all the details are been correct in my coding side.

What's this error, how to over come this?

7
  • 12
    did you try a clean build and a fresh install? Commented Mar 31, 2011 at 7:15
  • 1
    You seem to use the deprecated AbsoluteLayout? Can you post the code that is causing this error. Commented Mar 31, 2011 at 7:15
  • 1
    are you sure you changed nothing in layout xml file? Commented Mar 31, 2011 at 7:17
  • I think that there is some problem with layout java.lang.ClassCastException: android.widget.AbsoluteLayout 03-31 12:37:47.246: Commented Mar 31, 2011 at 7:18
  • i had made some changes in a layout which is related to other activity... Commented Mar 31, 2011 at 7:26

3 Answers 3

10

hi i have found my error, i have assigned linear layout in one of my xml file but i have mentioned it to be absolute layout in my class file.

Sign up to request clarification or add additional context in comments.

1 Comment

can you explain please please
5

ClassCastException in FirstImage class on line 106 ? It seems you try to cast something as an AbsoluteLayout in onCreate() method where it is not.

source :

Caused by: java.lang.ClassCastException: android.widget.AbsoluteLayout 03-31 12:37:47.246: ERROR/AndroidRuntime(1916): at com.fis.flash.FirstImage.onCreate(FirstImage.java:106)

Comments

2

I was getting this error Caused by: java.lang.ClassCastException: android.widget.LinearLayout cannot be cast to android.widget.TextView:

I changed

stringsAdapter = new ArrayAdapter<String>(this,R.layout.main,myStrings);

To

stringsAdapter = new ArrayAdapter<String>(this,android.R.layout.simple_expandable_list_item_1,myStrings);**

and problem is solved for me.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.