Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialGiuseppe Ienco
1,560 Pointscrystal ball has crashed.
can anyone help me. I followed the video step by step. i dont know where im going wrong. Also i dont understand how to read Logcat errors. can someone show me a link to where i can learn how to understand them. thankyou
- logcat 06-11 05:38:54.526: I/dalvikvm-heap(2190): Grow heap (frag case) to 3.691MB for 811216-byte allocation 06-11 05:38:54.596: D/dalvikvm(2190): GC_FOR_ALLOC freed <1K, 4% free 3715K/3868K, paused 68ms, total 68ms 06-11 05:38:54.736: D/AndroidRuntime(2190): Shutting down VM 06-11 05:38:54.736: W/dalvikvm(2190): threadid=1: thread exiting with uncaught exception (group=0xb1a2cba8) 06-11 05:38:54.756: E/AndroidRuntime(2190): FATAL EXCEPTION: main 06-11 05:38:54.756: E/AndroidRuntime(2190): Process: com.example.crystalball, PID: 2190 06-11 05:38:54.756: E/AndroidRuntime(2190): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.crystalball/com.example.crystalball.MainActivity}: java.lang.ClassCastException: android.widget.TextView cannot be cast to android.widget.Button 06-11 05:38:54.756: E/AndroidRuntime(2190): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195) 06-11 05:38:54.756: E/AndroidRuntime(2190): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) 06-11 05:38:54.756: E/AndroidRuntime(2190): at android.app.ActivityThread.access$800(ActivityThread.java:135) 06-11 05:38:54.756: E/AndroidRuntime(2190): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 06-11 05:38:54.756: E/AndroidRuntime(2190): at android.os.Handler.dispatchMessage(Handler.java:102) 06-11 05:38:54.756: E/AndroidRuntime(2190): at android.os.Looper.loop(Looper.java:136) 06-11 05:38:54.756: E/AndroidRuntime(2190): at android.app.ActivityThread.main(ActivityThread.java:5017) 06-11 05:38:54.756: E/AndroidRuntime(2190): at java.lang.reflect.Method.invokeNative(Native Method) 06-11 05:38:54.756: E/AndroidRuntime(2190): at java.lang.reflect.Method.invoke(Method.java:515) 06-11 05:38:54.756: E/AndroidRuntime(2190): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) 06-11 05:38:54.756: E/AndroidRuntime(2190): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 06-11 05:38:54.756: E/AndroidRuntime(2190): at dalvik.system.NativeStart.main(Native Method) 06-11 05:38:54.756: E/AndroidRuntime(2190): Caused by: java.lang.ClassCastException: android.widget.TextView cannot be cast to android.widget.Button 06-11 05:38:54.756: E/AndroidRuntime(2190): at com.example.crystalball.MainActivity.onCreate(MainActivity.java:23) 06-11 05:38:54.756: E/AndroidRuntime(2190): at android.app.Activity.performCreate(Activity.java:5231) 06-11 05:38:54.756: E/AndroidRuntime(2190): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 06-11 05:38:54.756: E/AndroidRuntime(2190): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159) 06-11 05:38:54.756: E/AndroidRuntime(2190): ... 11 more 06-11 05:38:59.826: I/Process(2190): Sending signal. PID: 2190 SIG: 9
3 Answers
Marcus Vieira
7,877 PointsHi Giuseppe!
The problem is here:
java.lang.ClassCastException: android.widget.TextView cannot be cast to android.widget.Button 06-11 05:38:54.756: E/AndroidRuntime(2190)
You're trying to cast a TextView
as a Button
, probably something like this:
TextView textView = (Button) findViewById( R.id.textView );
Instead, it should be:
TextView textView = (TextView) findViewById( R.id.textView );
I've tried looking up a tutorial on LogCat
but all I could find was how to write, not how to interpret it :(
What exactly do you not understand about it? is it simply too confusing ? Let me know, and I'll try to help!
Giuseppe Ienco
1,560 Pointsokay problem solved :)
i don't understand how to locate the problem. as there is heaps of errors shown in the LogCat. overall i guess i am still really new to the coding language so just find it confusing
Marcus Vieira
7,877 PointsOh, I see. A simple tip I can give you is to look for the name of your package + class, in this case com.example.crystalball.MainActivity
. That'll probably save you some minutes of looking around the LogCat
for graspable information.
Giuseppe Ienco
1,560 Pointsokay ill keep that in mind. thanks so much for taking the time to help :)