Android exception.getMessage() kills App
I have a question. Let's say I have the following code:
try{
//do something that could throw an exception
}
catch(Exception e){
System.out.println(e.getMessage();
}
Executing this in the emulator works开发者_开发知识库 fine, but when I tried to run it on my phone, the app craches (NullPointerException, apparently "e" is null).
How can that be?
Nope. If exception occurs than e
must have something inside (and thats the purpose).
If you use System.out to print your logs, you should be able to see the error in LogCat under the System.out
tag. Try checking that out and come back again.
精彩评论