18 April 2012

How to solve problem with java.lang.RuntimeException: Unable to start activity java.lang.ClassCastException: android.widget.LinearLayout ?

STORY:
So you create or update xml for layout and  run your program and instead of see your lovely active your receive annoying info your program sucks ...so Android will close it.
You looking to log and see:

java.lang.RuntimeException: Unable to start activity ComponentInfo
{name of your project}:
java.lang.ClassCastException: android.widget.LinearLayout
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1816)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1837)
at android.app.ActivityThread.access$1500(ActivityThread.java:132)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1033)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:143)
at android.app.ActivityThread.main(ActivityThread.java:4196)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassCastException: android.widget.LinearLayout
at org.ovh.pastor.diagnostictools.infos.PhoneInfo.onCreate(PhoneInfo.java:42)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1780)
... 11 more

So you check your activity class and it looks awesome
check your layout xml file and it is correct and you ask famous question
WTF?

SOLUTION:
Your IDE,ADB  get moody for no reason like girls before period and you need clean your project (In IntelliJ IDEA Bulid/Rebuild , In Eclipse Project/Clean).

No comments:

Post a Comment