Android google maps nullpointerexception

Thus, I see a peculiar exception, based on the fact that I am sure that this is the code for Google Maps.

I have a snippet where I programmatically add to SupportMapFragment and then I manipulate the GoogleMap instance inside 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.zdd(Unknown Source) 4 at maps.zda(Unknown Source) 5 at maps.aq.aa(Unknown Source) 6 at maps.aq.ao.b(Unknown Source) 7 at maps.aq.ao.a(Unknown Source) 8 at maps.vga(Unknown Source) 9 at maps.vgb(Unknown Source) 10 at maps.ppl(Unknown Source) 11 at maps.pprun(Unknown Source) 

I can not reliably reproduce it (although this happens quite often), I looked at ReadWriteDirectByteBuffer and ShortToByteBufferAdapter, but nothing came of me.

Any ideas?

+4
source share
2 answers

I had the same random issue.

You might want to try the problem in gmaps-api-issues .

+4
source

I had this problem and found that it was fixed in my application by implementing the .onPause () method for mapView in the onPause () method of the fragment in which MapView was located.

I think you need to implement all these methods inside the fragment and make sure that they are called in 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 about using the Fragment inside the fragment. Instead, I use MapView inside the fragment. See this post for how to do this: Android - android.view.InflateException: binary line of XML file # 8: error inflating a class fragment

+2
source

Source: https://habr.com/ru/post/1492789/


All Articles