What is the best way to debug the android code in Eclipse?

后端 未结 2 624
孤独总比滥情好
孤独总比滥情好 2020-12-02 02:49

I just start my hands on Eclipse and want to know what cause error in my apps. I wonder if their is a way like Visual Studio.

What I means is I have got Null pointer

2条回答
  •  無奈伤痛
    2020-12-02 03:43

    The best way to debug android using eclipse is to use breakpoints, catch exceptions, and use the log cat.

    Set breakpoints like you have been doing to try and locate the error.

    If the breakpoints aren't working then you can view the log cat and it may give you more information such as the line the error occurred on in your code.

    Then you could try catching exceptions:

    try{
      //do some stuff
    }catch(Exception e){
      Log.wtf("A terrible error occured.", e);
    }
    

    You could also check this post How to Debug Android application line by line using Eclipse? which tells you about more debugging methods.

提交回复
热议问题