No break on unhandled exception in the hello world tutorial

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

No break on unhandled exception in the hello world tutorial

Postby doc » Thu May 19, 2011 1:52 pm

Hello all.

First off all, let me introduce myself since this is my first post here.
Even if (as you would have noticed anyway) I am new to Android dev, I have quite a few years of coding behind me, using MS (C++, dotNet, WPF).

Today I've been through all steps of the hello world tutorial from the official site.
Everything worked as described, except that I've choosen a 2.3.3 target platform (the emulator seemed to me faster in that configuration).

My question is about the last part of this tutorial. They fire a NullPointerException to test debugging:
Code: Select all
public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Object o = null;
        o.toString();
        setContentView(R.layout.main);
    }


We are told to put a breakpoint before the exception is thrown, and eclipse breaks there... OK!

But I wanted to test a "normal life" scenario. In a normal life unhandled exception case, you have at the beginning no breakpoint. Your devenv breaks on unhandled exception, you get some info about that exception (call stack) that helps you putting some breakpoints and understand why the exception is being thrown...

In my case, without any breakpoint, Eclipse breaks (good!), but I have no clue at all about the exception.

First, it breaks in ActivityThread.performLaunchActivity(...) and not in my onCreate(...) code.
I have no source code for ActivityThread.performLaunchActivity(...) -see screenshot-, which seems normal to me.

On the top right of the debug screen, in Eclipse, I have a "Variables" tab. Into it, a "e" variable of type NullPointerException which may be my unhandled exception... But no clue in there: stack trace is null...
Member cause of the exception is also a NullPointerException, for which the cause is a NullPointerException, and so on, seamingly without end...

No info in log cat, no info in error log...

Screenshot:
Image

Could someone tell me if that behaviour from Eclipse is correct or not, and how to get info about the exception?

Thanks in advance...
doc
Freshman
Freshman
 
Posts: 2
Joined: Thu May 19, 2011 1:29 pm

Top

Re: No break on unhandled exception in the hello world tutor

Postby Whitt83 » Thu May 19, 2011 7:32 pm

That's typical from my experience. If something I did causes an exception in the onCreate method of an activity, I find I get very little useful information back to debug with.

Maybe somebody else has figured out a better method for debugging onCreate methods...
Whitt83
Junior Developer
Junior Developer
 
Posts: 11
Joined: Sun Apr 24, 2011 8:26 pm

Re: No break on unhandled exception in the hello world tutor

Postby raj_J2ME » Fri May 20, 2011 10:09 am

For debugging the code and its flows, I would recommend that we should use the IDE logger,that can be written by our self. I means, write the program, which prints some self explanatory lines on the console with the class name and time. using this you guy's can check that where was the exception occurred and in which class,
Thanks with Regards,
Raj - The Kernel
raj_J2ME
Master Developer
Master Developer
 
Posts: 311
Joined: Tue Feb 15, 2011 7:40 am
Location: The Capital of India,

Re: No break on unhandled exception in the hello world tutor

Postby doc » Fri May 20, 2011 8:22 pm

Thanks for your answers.
Whitt83, so it seems that its a problem of Android calling onCreate(...) and catching too many things. I'm at least happy that it is not a problem of my devenv install... ;)
raj_J2ME, If I understand you well, what you propose would cost extra development. but I'll keep the idea if I land sometime on a difficult problem...
doc
Freshman
Freshman
 
Posts: 2
Joined: Thu May 19, 2011 1:29 pm

Re: No break on unhandled exception in the hello world tutor

Postby raj_J2ME » Mon May 23, 2011 7:10 am

Yeah that will need to write the code, however this code will not be too long to write, it will bu only with few lines, and it will be reusable for you in your coming apps and development.. :)
Thanks with Regards,
Raj - The Kernel
raj_J2ME
Master Developer
Master Developer
 
Posts: 311
Joined: Tue Feb 15, 2011 7:40 am
Location: The Capital of India,

Top

Return to SDK/ADT/Emulator Problems

Who is online

Users browsing this forum: No registered users and 1 guest