• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Android Studio - NullPointerException

 
Titus Vasilescu
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys!I am getting a NullPointerException and I can't understand why.Here is my code:





Thanks in advance!Also I have a great idea for an application but having a very hard time writing it.If you would like to join me that would be great.
 
Tim Moores
Bartender
Posts: 3129
50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In which line does the exception occur? The full stack trace has that information. Also, which object is null? Have you checked that "mMap" is not null?
 
Titus Vasilescu
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the Logcat:

 
Tim Moores
Bartender
Posts: 3129
50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's just a single line? That's odd. Have you added additional logging to find out in which line the exception occurs, or stepped through it with a debugger?

Also:
Tim Moores wrote:Have you checked that "mMap" is not null?


Edited: I see, you're catching the exception, but do not print out the stacktrace. Change your catch handler to do that instead of discarding this vital information.
 
Titus Vasilescu
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the stacktrace and I get a different error here and yes the Google mMap is null but even so it is working when I remove the gotoLocation method.

 
Tim Moores
Bartender
Posts: 3129
50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Titus Vasilescu wrote: and yes the Google mMap is null

OK, so you need to figure out why the code that's supposed to initialize it fails to do that. That happens in code you didn't post, so we can't help with that.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic