Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to view exception details while debugging Android in Eclipse?

I've just started learning how to develop applications for Android. Currently, I am using Eclipse 4.2 (Juno) as the IDE. The problem is I can't see a normal way to view exceptions that are happening in my own code. For example:

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    List<BasicObject> objects = _objectRepository.GetAllObjects();
    Iterator<BasicObject> iterator = objects.iterator();

    while(iterator.hasNext())
    {
        ObjectListItemView itemView= new ObjectListItemView(this,iterator.next());
    }
}

At the time when onCreate is running, _objectRepository is null and so the NullReference is thrown. After that Eclipse displays "Source not found", which is really not what I expect. Then I press F8 (continue) multiple times; the process exits and the debugger stops. And only after that can I see some stacktrace in LogCat (from where it's really hard to navigate to my own code).

As you can see, all this process of catching exceptions is really time-consuming. Is there any other way to view exceptions and what am I doing wrong?

I am not using an Android emulator, I am using a real device (HTC Desire S). I already have LogCat, but I'd like something more handy/practical.

To illustrate, in Visual Studio I can see an exception while debugging. Visual Studio sets a break on the line where the exception occurred and I can view any information I want (stack trace local variables, all stuff actually) in the exception window (see The {not much utilized} Debug->Exceptions… window technique).

In Eclipse I got exception details in LogCat (which is very uncomfortable to use) and only after the debugger is stopped.

like image 387
armless-coder Avatar asked Sep 19 '26 09:09

armless-coder


1 Answers

You can enable LogCat for Android like this:

In Eclipse, go to Window -> Show View -> Other -> Android -> Logcat.

Logcat is nothing but a console of your emulator or device.

How to enable logcat/Console in Eclipse for Android?

like image 168
UVM Avatar answered Sep 21 '26 23:09

UVM



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!