Inconvertible types; cannot cast 'android.support.v4.app.Fragment' to 'com.google.android.gms.maps.SupportMapFragment'

I also struggled with this issue, but it turns out that the new version of google maps uses AndroidX from 17.0.0. So you should use 16.1.0

So change this:

implementation 'com.google.android.gms:play-services-maps:17.0.0'

To this:

implementation 'com.google.android.gms:play-services-maps:16.1.0'

Also, make sure that you don't use any that uses AndroidX: in my case, I used this which caused trouble:

implementation 'com.google.android.gms:play-services-location:17.0.0'

so I also made this to

implementation 'com.google.android.gms:play-services-location:16.0.0'

This is the list of versions; https://mvnrepository.com/artifact/com.google.android.gms/play-services-maps

for correct versions of google play services: https://developers.google.com/android/guides/releases

Tags:

Java