Forum Xamarin.Android

Can a AutocompleteSupportFragment be used inside an AndroidX.Fragment.App.Fragment?

I have a fragment that inherits from Android.Support.V4.App.Fragment, and inside that fragment I've added an AutocompleteSupportFragment from the Android Places SDK. To initialize the autocomplete fragment, I do the following code:

public class PlacesFragment : Android.Support.V4.App.Fragment, Google.Places.IPlaceSelectionListener

    public override void OnViewCreated(View view, Bundle savedInstanceState)
        base.OnViewCreated(view, savedInstanceState);

        var autocompleteFragment = (AutocompleteSupportFragment)ChildFragmentManager.FindFragmentById(Resource.Id.autocompleteFragment);

        var fields = new List<Google.Places.Place.Field>



This works as expected and there are no problems whatsoever.

Now, since the Android Support Libraries will no longer be maintained (as stated by the docs), I wanted to migrate the PlacesFragment to the latest AndroidX libraries. The issue is that if I change the PlacesFragment to inherit from AndroidX.Fragment.App.Fragment, an error CS0030 Cannot convert type 'AndroidX.Fragment.App.Fragment' to 'Google.Places.AutocompleteSupportFragment' appears in the statement var autocompleteFragment = (AutocompleteSupportFragment)ChildFragmentManager.FindFragmentById(Resource.Id.autocompleteFragment);, which makes sense because the AutocompleteSupportFragment still inherits from Android.Support.V4.App.Fragment.

Am I missing something? Is it possible to use the AutocompleteSupportFragment from the Android Places SDK inside an AndroidX fragment?

I'm using version of the Xamarin.Google.Android.Places nuget package which, as far as I can tell, is the latest available version.

Thanks in advance


  • LandLuLandLu Member, Xamarin Team Xamurai

    I'm afraid this library may be out of date as its dependencies are all support libraries:

    And the latest native places SDK has reached 2.4.0:
    If you do need this library, we need to revert back to support or create the binding library by ourselves.

  • DuarteDuarte USBeta ✭✭

    @LandLu, thank you for your reply.

    Yes, I do need this library, it's one the requirements of the app that I'm developing. Since the Xamarin.Google.Android.Places nuget package is owned by Microsoft and Xamarin, my expectation was that it was kept up to date with the rest of your libraries. That being said, I have a couple of follow up questions:
    1. Can you tell me when (if at all) can I expect this library to be updated to the latest native places SDK?
    2. Is there any way I can expedite this process so that this update is done quicker?

  • RajMuppasaniRajMuppasani USMember
    edited March 12


    I have exactly the same problem. Is this resolved? Could you please share the details?

    Any help would be greatly appreciated.

    Thank you

  • DuarteDuarte USBeta ✭✭

    Hi @RajMuppasani,

    I ended up raising an issue on Github. It has been open since September last year and apparently no progress has been made.

    So, to answer your question directly, this problem isn't resolved. For this reason my app is still using Xamarin Android Support libraries instead of the latest AndroidX libraries.

  • RajMuppasaniRajMuppasani USMember
    edited March 15

    Hi @Duarte,

    Thank you for the update. Will wait until the libraries are updated. For now, I will use the work around JavaCast<AutocompleteSupportFragment>.


Sign In or Register to comment.