Google地图在特定位置和缩放级别15崩溃

时间:2018-01-16 04:55:20

标签: android-mapview

Google地图在Android 8(API级别26)的特定位置(35.670,139.760)处以缩放级别15崩溃。

其他缩放级别没有崩溃(例如:1,2,10或14等)

崩溃时,Logcat输出为:

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)

......

通过在Nexus5X And​​roid 8模拟器中运行以下代码,可以很容易地重现

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));
    }
}

1 个答案:

答案 0 :(得分:1)

这是Google Maps SDK中的一个长期存在的错误,请参阅https://issuetracker.google.com/issues/35829548

您可以通过禁用室内地图来解决此问题:

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

问题也是Is there a workaround/fix to these Google Maps v2 StackOverflowError crashes?

的副本