2011-07-27 34 views
1

我有一个问题。比方说,我有以下代码:Android exception.getMessage()kill App

try{ 
    //do something that could throw an exception 
} 
catch(Exception e){ 
    System.out.println(e.getMessage(); 
} 

在模拟器中执行此工作正常,但是当我试图在我的手机上运行,​​应用程序craches(NullPointerException异常,显然是“E”为空)。

这怎么可能?

回答

1

没有。如果发生异常,比e内部必须有东西(那就是目的)。

+0

好吧,这就是我的想法。然而,现在似乎问题不再出现,出于某种原因... – deimos1988

0

如果您使用System.out来打印日志,您应该能够在System.out标记下看到LogCat中的错误。尝试检查出来,然后再回来。