Attempt to get length of null array in google maps V2 android app

匿名 (未验证) 提交于 2019-12-03 08:41:19

问题:

I am currently developing an android application using google maps api and I sometimes get a weird crash (in my opinion) for no ovious reason. Here's the crash log :

12-02 16:38:57.071  20796-21137/com.appsolute.ParkYoo E/AndroidRuntime: FATAL EXCEPTION: GLThread 4623     Process: com.appsolute.ParkYoo, PID: 20796     java.lang.NullPointerException: Attempt to get length of null array             at java.nio.DirectByteBuffer.put(DirectByteBuffer.java:399)             at java.nio.ByteBufferAsShortBuffer.put(ByteBufferAsShortBuffer.java:159)             at com.google.maps.api.android.lib6.gmm6.o.c.a.d.d(Unknown Source)             at com.google.maps.api.android.lib6.gmm6.o.c.a.d.a(Unknown Source)             at com.google.maps.api.android.lib6.gmm6.o.a.a(Unknown Source)             at com.google.maps.api.android.lib6.gmm6.o.c.b(Unknown Source)             at com.google.maps.api.android.lib6.gmm6.o.c.a(Unknown Source)             at com.google.maps.api.android.lib6.gmm6.o.l.a(Unknown Source)             at com.google.maps.api.android.lib6.gmm6.o.l.b(Unknown Source)             at com.google.maps.api.android.lib6.gmm6.o.cw.k(Unknown Source)             at com.google.maps.api.android.lib6.gmm6.o.cw.run(Unknown Source) 

As you can see, the crash happens in google api but the code has been obfuscated so I don't have more infos about that except on the 2 first lines :

final void put(short[] src, int srcOffset, int shortCount) {     checkIsAccessible();     int byteCount = checkPutBounds(SizeOf.SHORT, src.length, srcOffset, shortCount); // here is the error     this.block.pokeShortArray(offset + position, src, srcOffset, shortCount, order.needsSwap);     position += byteCount;   }  @Override     public ShortBuffer put(short[] src, int srcOffset, int shortCount) {         byteBuffer.limit(limit * SizeOf.SHORT);         byteBuffer.position(position * SizeOf.SHORT);         if (byteBuffer instanceof DirectByteBuffer) {             ((DirectByteBuffer) byteBuffer).put(src, srcOffset, shortCount);         } else {             ((ByteArrayBuffer) byteBuffer).put(src, srcOffset, shortCount);         }         this.position += shortCount;         return this;     } 

Has anyone already encountered this bug ? What am I doing wrong ? If anybody has an insight concerning this issue, I'll be pleased to discuss it.

Thanks !

回答1:

You're likely running more than one map fragment. See my writeup on this fatal bug currently haunting the Google Maps library, concerning multiple map fragments - and how I found a workaround.

http://www.aphex.cx/the_google_maps_api_is_broken_on_android_5_here_s_a_workaround_for_multiple_map_fragments/

Google is currently working on the case and is prioritizing it for the next release of Google Play Services!



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!