Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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 !

like image 221
user3476114 Avatar asked Dec 02 '14 15:12

user3476114


1 Answers

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.

https://medium.com/aphex-cx/the-google-maps-api-is-broken-on-android-5-heres-a-workaround-for-multiple-map-fragments-6a95655c92fd

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

like image 131
Aphex Avatar answered Sep 24 '22 20:09

Aphex