question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot find a child SupportMapFragment from an AndroidX Fragment

See original GitHub issue

I think this is a known issue on the Google side, but I’m not sure if it has been sorted yet or is going to propagate to Xamarin soon:

Stack overflow issue

I have a SupportMapFragment, which inherits Support.V4.App.Fragment. Before I migrated to AndroidX I had this line:

_mapFragment = (SupportMapFragment)ChildFragmentManager.FindFragmentById(Resource.Id.map);

Now I get a casting error because the AndroidX fragment’s child fragment manager doesn’t return a support fragment.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:14 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
Redthcommented, Feb 5, 2020

What if you use:

_mapFragment = ChildFragmentManager.FindFragmentById(Resource.Id.mapZone).JavaCast<SupportMapFragment>();
1reaction
ToddThomsoncommented, Feb 28, 2020

@Ryan-Palmer Thank-you for all your help! Sorry for the confusion - I had previously used an xml layout with a SupportMapFragment with the V4 support libs. I have now gone back to that code. Given your help with the JavaCast<SupportMapFragment>() the nested fragment is now working fine.

I am not sure when or why I changed my code, but having an xml layout for a UI fragment seems correct even if it is only has a SupportMapFragment based fragment contained within it.

Thanks again Ryan!

Read more comments on GitHub >

github_iconTop Results From Across the Web

SupportMapFragment does not support AndroidX Fragment
Looking at the error message you posted, I suspect this was the main issue in your case. The definition in your layout file...
Read more >
SupportMapFragment | Maps SDK for Android
This fragment is the simplest way to place a map in an application. It's a wrapper around a view of a map to...
Read more >
How to find a child Fragment with Navigation Architecture ...
findFragmentById (R.id.map) as SupportMapFragment actually find a nested navigation graph. If you just want to get access to your child fragment, ...
Read more >
Create Google Map with MVVM Live Data in Fragment with ...
SupportMapFragment 3) Edit the created Fragment.kt file to remove ... First, it will check to see if the map is ready, and if...
Read more >
Android SupportMapFragment Example
The reason for doing this is, we need to use a method getSupportFragmentManager(), and this method can be called in FragmentActivity class only....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found