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.
The OS has to do a few things in order to get a message to logcat; these are triggered by the (uncaught) exception. If you try to step through them in the debugger it is tedious and you get “Source not found” a lot (that’s system code, not yours).
Irritating, but it is a safe bet that whatever happens after the exception does not happen inside your app, so you might as well stop at that point anyway. If you need to see the logcat report of an exception quickly, just run the app without the debugger.