I’m trying to use LogCat to debug a simple app that reads an XML file in my res folder.
I keep getting this error in my Eclipse LogCat window:
01-03 10:21:30.741: W/dalvikvm(356): threadid=1: thread exiting with uncaught exception (group=0x40014760)
E/AndroidRuntime(356): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{tot.HelloAndroid/tot.HelloAndroid.HelloAndroid}: java.lang.NullPointerException: println needs a message
This doesn’t seem to helpful to me. I am using a try/catch block like this. Does this look ok?
public XmlParser() throws XmlPullParserException, IOException {
try {
XmlPullParser xpp = getResources().getXml(R.xml.encounters);
// ...do stuff...
} catch (Exception e) {
Log.e("error", e.getMessage());
}
//...
If the error message is
null(which can be the case if the error message has not been set), you try to print nothing, a simple fix is to useor
You might also want to call
e.printStackTrace()to get more detailed information.