4

So I've been seeing a peculiar exception coming from what I'm pretty sure is Google Maps drawing code.

I've got a Fragment, where I programatically add in a SupportMapFragment, and then I manipulate the GoogleMap instance within it.

Here's the stacktrace:

0   java.lang.NullPointerException

1   at java.nio.ReadWriteDirectByteBuffer.put(ReadWriteDirectByteBuffer.java:137)

2   at java.nio.ShortToByteBufferAdapter.put(ShortToByteBufferAdapter.java:163)

3   at maps.z.d.d(Unknown Source)

4   at maps.z.d.a(Unknown Source)

5   at maps.aq.a.a(Unknown Source)

6   at maps.aq.ao.b(Unknown Source)

7   at maps.aq.ao.a(Unknown Source)

8   at maps.v.g.a(Unknown Source)

9   at maps.v.g.b(Unknown Source)

10  at maps.p.p.l(Unknown Source)

11  at maps.p.p.run(Unknown Source)

I can't reliably replicate it (although it's happening quite often), I've looked at ReadWriteDirectByteBuffer and ShortToByteBufferAdapter but nothing pops out at me.

Any ideas?

Kara
  • 6,115
  • 16
  • 50
  • 57
  • I've come with a workaround for this. It's not a fix but at least avoids having the app crash all the time. Check out my own answer here: http://stackoverflow.com/questions/19624437/random-nullpointerexception-on-google-maps-api-v2/19627149#19627149 – Victor Elias Oct 28 '13 at 04:25

2 Answers2

4

I have had the same random problem.

You may want to try to ressurect the issue on gmaps-api-issues.

MaciejGórski
  • 22,187
  • 7
  • 70
  • 94
2

I had this problem and found it was fixed in my app by implementing the .onPause() method of the mapView in the onPause() method of the Fragment the MapView was in.

I think you need to implement all these methods within the Fragment and ensure they are called on your MapView.

MapView mapView; 

@Override
public void onResume() {
    mapView.onResume();
    super.onResume();
}

@Override
public void onDestroy() {
    super.onDestroy();
    mapView.onDestroy();
}

@Override
public void onPause() {
    super.onPause();
    mapView.onPause();
}

@Override
public void onLowMemory() {
    super.onLowMemory();
    mapView.onLowMemory();
}

I see that the original poster talks of using a Fragment within a Fragment. I am using MapView within a Fragment instead. See this post for how to do this: Android - android.view.InflateException: Binary XML file line #8: Error inflating class fragment

Community
  • 1
  • 1
TTransmit
  • 3,270
  • 2
  • 28
  • 43