JasonZ
JasonZ

Reputation: 43

Google Map crash at specific location and zoom level 15

Google Map crashes with zoom level 15 at specific location (35.670, 139.760) on Android 8 (API level 26).

No crash with other zoom levels (say: 1,2,10, or 14 etc.)

When crash, the Logcat output is:

E/AndroidRuntime: FATAL EXCEPTION: GLThread 279
              Process: test.map, PID: 5690
              java.lang.StackOverflowError: stack size 1038KB
                  at java.util.Collections$UnmodifiableList.<init>(Collections.java:1344)
                  at java.util.Collections$UnmodifiableRandomAccessList.<init>(Collections.java:1437)
                  at java.util.Collections.unmodifiableList(Collections.java:1330)
                  at com.google.maps.api.android.lib6.common.g.<init>(:com.google.android.gms.DynamiteModulesB@11951470:9)
                  at com.google.maps.api.android.lib6.gmm6.indoor.o.b(:com.google.android.gms.DynamiteModulesB@11951470:142)
                  at com.google.maps.api.android.lib6.gmm6.indoor.o.c(:com.google.android.gms.DynamiteModulesB@11951470:144)
                  at com.google.maps.api.android.lib6.gmm6.indoor.o.e(:com.google.android.gms.DynamiteModulesB@11951470:286)
                  at com.google.maps.api.android.lib6.gmm6.indoor.o.d(:com.google.android.gms.DynamiteModulesB@11951470:182)
                  at com.google.maps.api.android.lib6.gmm6.indoor.o.a(:com.google.android.gms.DynamiteModulesB@11951470:180)
                  at com.google.maps.api.android.lib6.gmm6.indoor.o.a(:com.google.android.gms.DynamiteModulesB@11951470:82)
                  at com.google.maps.api.android.lib6.gmm6.indoor.o.a(:com.google.android.gms.DynamiteModulesB@11951470:70)
                  at com.google.maps.api.android.lib6.gmm6.indoor.o.c(:com.google.android.gms.DynamiteModulesB@11951470:147)
                  at com.google.maps.api.android.lib6.gmm6.indoor.o.e(:com.google.android.gms.DynamiteModulesB@11951470:286)
                  at com.google.maps.api.android.lib6.gmm6.indoor.o.d(:com.google.android.gms.DynamiteModulesB@11951470:182)
                  at com.google.maps.api.android.lib6.gmm6.indoor.o.a(:com.google.android.gms.DynamiteModulesB@11951470:180)
                  at com.google.maps.api.android.lib6.gmm6.indoor.o.a(:com.google.android.gms.DynamiteModulesB@11951470:82)
                  at com.google.maps.api.android.lib6.gmm6.indoor.o.a(:com.google.android.gms.DynamiteModulesB@11951470:70)
                  at com.google.maps.api.android.lib6.gmm6.indoor.o.c(:com.google.android.gms.DynamiteModulesB@11951470:147)
                  at com.google.maps.api.android.lib6.gmm6.indoor.o.e(:com.google.android.gms.DynamiteModulesB@11951470:286)
                  at com.google.maps.api.android.lib6.gmm6.indoor.o.d(:com.google.android.gms.DynamiteModulesB@11951470:182)

......

It's very easy to reproduce by running the following code in Nexus5X Android 8 emulator

package test.map;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.LinearLayout;

import com.google.android.gms.maps.CameraUpdate;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapView;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.model.LatLng;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        //
        LinearLayout ll = new LinearLayout(this);
        ll.setOrientation(LinearLayout.VERTICAL);

        setContentView(ll);

        //    
        MapView mapView = new MapView(this);
        mapView.onCreate(null);
        mapView.onResume();
        mapView.getMapAsync(new OnMapReadyCallback() {
            @Override
            public void onMapReady(final GoogleMap googleMap) {
                final LatLng latLng = new LatLng(35.670, 139.760);
                final CameraUpdate update = CameraUpdateFactory.newLatLngZoom(latLng, 15.0f);
                googleMap.moveCamera(update);
            }
        });

        ll.addView(mapView, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT));
    }
}

Upvotes: 4

Views: 1264

Answers (1)

mindeh
mindeh

Reputation: 1818

This is a long standing bug in Google Maps SDK, see https://issuetracker.google.com/issues/35829548

You can the issue this by disabling indoor maps:

@Override public void onMapReady(GoogleMap googleMap) {
    googleMap.setIndoorEnabled(false);
}

Question is also a duplicate of Is there a workaround/fix to these Google Maps v2 StackOverflowError crashes?

Upvotes: 4

Related Questions