25

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 !

user3476114
  • 564
  • 6
  • 17
  • well how about showing what you are doing in your code – tyczj Dec 02 '14 at 15:56
  • 2
    Hi and thanks for your answer. As I said, this doesn't happen in my code but in the maps lib code. Anyway I'm eager to show you my code but what do you want to see ? At the moment I set up 2 GoogleMaps in tabbed activity. – user3476114 Dec 02 '14 at 16:18
  • I'm getting the same crash, but it wasn't happening before. Are you running your app on Lollipop? I'm thinking it has to do with it – wmora Dec 04 '14 at 14:49
  • Hi wmora. Yes my apps runs on Lollipop but it also happened on my nexus 4 which still is on KitKat (4.4.4) and running with dalvik runtime. Still a mystery to me... – user3476114 Dec 05 '14 at 09:28
  • reported this issue in Crashlytics for my app for both 5.1 & 6.0.1 on Vivo device and that too occasionally. And I have been never able to reproduce the issue – Shirish Herwade Mar 23 '18 at 06:32

1 Answers1

14

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!

lewkka
  • 940
  • 14
  • 23
Aphex
  • 7,220
  • 5
  • 32
  • 53