简体   繁体   中英

Where can I find the reason for java.lang.NullPointerException

When I debug my application I get errors in the LogCat, something like this:

E/AndroidRuntime(27367): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.****/com.****}: java.lang.NullPointerException

Is there a way to know where exactly in the code the exception came from? what was this NULL ?

In many other language when you get this kind of problems it tells you the file and line where it all started

Is there a way of getting it in java and android sdk as well?

If you look further down the stack trace it will tell you exactly where it occurred by file name and line number. Post the full stack trace if you'd like, but it should be easy to find.

If you have multiple object accessors at that line, either break them out into multiple lines or set a breakpoint and go into debug mode

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM