Android Forum » Android Developer Forum » Android Developer Forum » New Learner.. Not able to run app and it force closes.

New Learner.. Not able to run app and it force closes.

New Learner.. Not able to run app and it force closes.
created on Dec 17, 2012 9:54:00 AM
watching android app development from eclipse.
There is no error in development phase but when running it , the LOGCAT gives the below error:

12-17 13:50:17.448: W/dalvikvm(729): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
12-17 13:50:17.478: E/AndroidRuntime(729): FATAL EXCEPTION: main
12-17 13:50:17.478: E/AndroidRuntime(729): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.thenewboston.vrsaxena/com.thenewboston.vrsaxena.StartingPoint}: java.lang.ClassCastException: android.widget.TextView cannot be cast to android.widget.Button
12-17 13:50:17.478: E/AndroidRuntime(729): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
12-17 13:50:17.478: E/AndroidRuntime(729): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
12-17 13:50:17.478: E/AndroidRuntime(729): at android.app.ActivityThread.access$600(ActivityThread.java:130)
12-17 13:50:17.478: E/AndroidRuntime(729): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
12-17 13:50:17.478: E/AndroidRuntime(729): at android.os.Handler.dispatchMessage(Handler.java:99)
12-17 13:50:17.478: E/AndroidRuntime(729): at android.os.Looper.loop(Looper.java:137)
12-17 13:50:17.478: E/AndroidRuntime(729): at android.app.ActivityThread.main(ActivityThread.java:4745)
12-17 13:50:17.478: E/AndroidRuntime(729): at java.lang.reflect.Method.invokeNative(Native Method)
12-17 13:50:17.478: E/AndroidRuntime(729): at java.lang.reflect.Method.invoke(Method.java:511)
12-17 13:50:17.478: E/AndroidRuntime(729): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
12-17 13:50:17.478: E/AndroidRuntime(729): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
12-17 13:50:17.478: E/AndroidRuntime(729): at dalvik.system.NativeStart.main(Native Method)
12-17 13:50:17.478: E/AndroidRuntime(729): Caused by: java.lang.ClassCastException: android.widget.TextView cannot be cast to android.widget.Button
12-17 13:50:17.478: E/AndroidRuntime(729): at com.thenewboston.vrsaxena.StartingPoint.onCreate(StartingPoint.java:22)
12-17 13:50:17.478: E/AndroidRuntime(729): at android.app.Activity.performCreate(Activity.java:5008)
12-17 13:50:17.478: E/AndroidRuntime(729): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
12-17 13:50:17.478: E/AndroidRuntime(729): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
12-17 13:50:17.478: E/AndroidRuntime(729): ... 11 more


Please HELP... :(
Reply with quote Reply Link ±0     (0 votes)
RE: New Learner.. Not able to run app and it force closes.
created on Dec 17, 2012 10:24:54 AM
Just for additional information:
I am using
AVD - Platform 4.1 , API Level 16, CPU/ABI ARM (armeabi-v7a)

Please let me know if you want some more information for resolving the issue.
I am watching videos from EDU ( LifeLong Learning ) The NewBoston android application series and just made the app from watching the 10th video.
Its a simple Buttons app with add and subtract values.

There are no errors while Building, its just not able to run and gives the above error in LOGCAT in eclipse as shown above.
Reply with quote Reply Link ±0     (0 votes)
RE: New Learner.. Not able to run app and it force closes.
created on Dec 17, 2012 1:21:20 PM — modified on Dec 17, 2012 1:22:07 PM
Debug step by step inside onCreate.
I guess your findViewById searches for the wrong widget. (cast TextView to Button)

-----
Meine App: Time Sheriff - The easy all in one timer

Reply with quote Reply Link ±0     (0 votes)
RE: New Learner.. Not able to run app and it force closes.
created on Dec 17, 2012 10:43:36 PM
Thanks a lot Andreas .
I was using display variable as Button instead of TextView.

It solved the problem and its running.. Thanks a lot again.. :)
Reply with quote Reply Link ±0     (0 votes)
RE: New Learner.. Not able to run app and it force closes.
created on Dec 27, 2012 7:08:40 PM
You are trying to cast a TextView into a Button. Check your xml layout (look the id of the widget)

java.lang.ClassCastException: android.widget.TextView cannot be cast to android.widget.Button
Reply with quote Reply Link ±0     (0 votes)
RE: New Learner.. Not able to run app and it force closes.
created on Feb 4, 2013 9:36:54 AM
Use try{
}catch..You will be able to find missing element in the Android emulator,through that you can debug your code,
Reply with quote Reply Link ±0     (0 votes)