import com.google.android.gms.maps.SupportMapFragment;
import androidx.fragment.Fragment;
...
private SupportMapFragment mMapFragment;
...
mMapFragment = (SupportMap
Make sure that in the fragment java class you import androidx.fragment.app.Fragment;
and in the java class from where you refer to this particular fragment, you also import Fragment the same way i.e. import androidx.fragment.app.Fragment;
After that to get a reference of the fragment we created, use getSupportFragmentManager().findFrgmentById(R.id.fragment_id)
.
To summarise, make sure you have the same import in all concerned Java or Kotlin classes.
Android Jetifier unfortunately did not work for me. I solved this problem by copying SupportMapFragment
to my project and changing the parent. During this procedure I also had to make copy of class called zzak
(renamed it to SupportMapCallback
).
Please note that you should take this solution as temporary cause right now it's independent on updates of Play Services library. If you also need to migrate to AndroidX as soon as possible then feel free to grab it from here:
https://gist.github.com/mroczis/3988e390a8b04fad3c8714181718cd60
For this to work you must be on the following version or higher:
com.google.android.gms:play-services-maps:16.0.0
After migrating to AndroidX, be sure to invalidate caches and restart to get rid of all the red errors on the Google Maps dependencies.
You need to update the Android studio version to more than 3.2 it's still a beta version. The problem is Google Maps library is using Fragment class from the support library so it's conflicted with androidX, so Android Studio 3.2 version make refactor all dependencies to use androidX classes.