9

After I updated my dependencies my getMap() won't work. (it used to work just fine before update)

Here is the line of codes i get error

GoogleMap map = ((MapView) mRootView.findViewById(R.id.fragment_map_mapview)).getMap();

Location locationNet = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
Location locationGps = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);

The grandle code

dependencies
        {
            compile 'com.android.support:support-v4:24.0.0'
            compile 'com.android.support:appcompat-v7:24.0.0'
            compile 'com.android.support:cardview-v7:24.0.0'
            compile 'com.android.support:recyclerview-v7:24.0.0'
            //compile 'com.google.android.gms:play-services:7.3.0'
            compile 'com.google.android.gms:play-services:9.2.0'
            compile 'com.afollestad:material-dialogs:0.6.3.4@aar'
            compile 'com.bignerdranch.android:recyclerview-multiselect:0.1'
            compile 'com.j256.ormlite:ormlite-android:4.48'
            compile 'com.melnykov:floatingactionbutton:1.2.0'
            compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.3'
            compile 'se.emilsjolander:StickyScrollViewItems:1.1.0'
            compile 'com.squareup.picasso:picasso:2.5.2'
            compile fileTree(include: ['*.jar'], dir: 'libs')
        }
AresProductions
  • 508
  • 1
  • 9
  • 23
  • 2
    Possible duplicate of [Replace getMap with getMapAsync](http://stackoverflow.com/questions/31371865/replace-getmap-with-getmapasync) – N Dorigatti Jul 08 '16 at 12:47
  • 1
    @NDorigatti and @Owais Ali are correct, you need to use [`getMapAsync()`](https://developers.google.com/android/reference/com/google/android/gms/maps/MapFragment) method. – Android Enthusiast Jul 09 '16 at 07:39

1 Answers1

11

getMap() method is a deprecated API which was removed in Google Play Services 9.2. You'll need to replace this with getMapAsync() everywhere (or stay with the older release of Play Services).

Garg
  • 2,731
  • 2
  • 36
  • 47
Owais Ali
  • 724
  • 1
  • 6
  • 14