NoSuchFieldError: No static field MapAttrs of type when Using MapFragment with Play Services 6.5

后端 未结 5 739
南方客
南方客 2020-12-07 22:56

Maybe I am missing something here, but I am not able to use the new Maps only dependency in Play Services 6.5

I get the following exception:

java.la         


        
5条回答
  •  独厮守ぢ
    2020-12-07 23:19

    Interim solution

    replace the xml map fragment with a FrameLayout container

    
    
    
    
    
    
    

    Create the fragment in code and replace the container

    SupportMapFragment supportMapFragment = SupportMapFragment.newInstance();
    getSupportFragmentManager().beginTransaction().replace(R.id.map_container,supportMapFragment).commit();
    
    //this you should do anyway
    supportMapFragment.getMapAsync(new OnMapReadyCallback() {
        @Override
        public void onMapReady(GoogleMap googleMap) {
            //setup map - optional
            UiSettings settings = googleMap.getUiSettings();
            settings.setCompassEnabled(false);
            settings.setZoomControlsEnabled(false);
            settings.setAllGesturesEnabled(true);
            settings.setMyLocationButtonEnabled(true);
        }
    });
    

    Please note that the above was done in 'onCreate' in an activity without any other fragments, so make sure you adapt the transaction to your lifecycle and logic.

提交回复
热议问题