question about debug on Eclispe

Common bugs/problems with the Android SDK the Emulator and the ADT-Plugin.

Re: question about debug on Eclispe

Postby huascar82 » Thu Apr 14, 2011 1:58 am

FC stands for "Force Close", the window you see in either an android phone or the emulator that indicates the app has/is about to crash. During debug this would usually come up after a couple of times of clicking on resume once your project drops into an error. Switch to DDMS perspective so you can see the logcat, click Force Close in your Emulator to force the debugging app to close, and you'll see a few red lines shoot from the bottom of your logcat pane. This stack of errors will be from your project. Usually towards the top of the stack you'll see 1 or 2 lines that relate directly to your code and not just android's code. This is the dump I get when I run your code. If you notice the second line says something about "ClassCastException" and points at an android.widget.textview in the testerror.errordebug class. While down further on the stack towards the end it says "Caused by" and again points to the ClassCastException. One line actually points you to the java file that caused the error and the line number.
com.test.testerror.errordebug.onCreate(errordebug.java:15) In my test that's actually the line that created the b Button object, it doesn't even get to the ispressed code.

It may not show it to you as easily or as clearly as either of us is used to but I guess you have to get yourself used to doing things different in different enviornments.

    FATAL EXCEPTION: main
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test.testerror/com.test.testerror.errordebug}: java.lang.ClassCastException: android.widget.TextView
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1768)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1784) $1500(ActivityThread.java:123)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:123)
    at android.app.ActivityThread.main(ActivityThread.java:3839)
    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:841)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
    at dalvik.system.NativeStart.main(Native Method)
    Caused by: java.lang.ClassCastException: android.widget.TextView
    at com.test.testerror.errordebug.onCreate(errordebug.java:15)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1722)


As for using the try catch block, this was the code I used. Instead dropping out of normal run mode and forcing you to click resume thru the "source not found" thing, it just skips it but prints to logcat in an orange looking text. The top 2 lines in the stack point you to the line in your code that caused the exception.

java.lang.ClassCastException: android.widget.TextView
at com.test.testerror.errordebug.onCreate(errordebug.java:16)

Code: Select all
try {
        Button b = (Button) findViewById(R.id.textview1);
         b.isPressed();
    }
    catch (Exception e){
        e.printStackTrace();
    }
huascar82
Freshman
Freshman
 
Posts: 6
Joined: Tue Apr 12, 2011 10:02 pm

Top
Previous

Return to SDK/ADT/Emulator Problems

Who is online

Users browsing this forum: No registered users and 4 guests