I have a screen that's making use of `AndroidView`...
# compose
j
I have a screen that's making use of
AndroidView
to contain a layout that in turn contains a
com.google.android.gms.maps.SupportMapFragment
. It works fine if that's only screen but just added some navigation and when I show another screen and then come back to this one again I'm getting following. Is there any recommended approach available right now to work around this?
Copy code
Binary XML file line #6: Duplicate id 0x7f08009a, tag null, or parent id 0xffffffff with another fragment for com.google.android.gms.maps.SupportMapFragment
l
can you file bug for this?
j
just created https://issuetracker.google.com/issues/160765224 ....let me know if you need any more info
I guess this is general issue for child fragments included this way....but is hope that a Google map will be supported as first class composable?
i
Also, please never use the
<fragment>
tag, use
FragmentContainerView
j
I switched it to use
FragmentContainerView
....it doesn't crash now when I show that "screen" again but just does't render map
i
Makes sense. Removing the parent view that hosts one or more Fragments (which I would assume would be the case when you go to your next screen and the
AndroidView
is no longer in the composition) doesn't do anything to the FragmentManager's state - the Fragment would still be in the resumed state, trucking along. Same is true in the non-Compose world
(which is WAI and required to support cases such as ViewPager2 where they are controlling the placement and attachment of a Fragment's view with the overall hierarchy)
m
@John O'Reilly Hi I wanna use map and see your weblog, but seems that not woking. Main error is the way you used android view.
Copy code
AndroidView(resId = R.layout.map_layout, modifier = Modifier.weight(0.4f)) {
j
@Mahdi that project is still using alpha04....perhaps something has changed since then. Will try and grab some time later and take a look. What error are you seeing btw?
m
Thanks John. In your method that part is not working any more. I'm looking for new ways. If you had time please take look at this: https://stackoverflow.com/q/64690821/1498586
j
https://github.com/joreilly/galway-bus-android is the project that's still on alpha04.....but.....I think I updated that since that article, primarily based on what was in Crane app which it sounds like you've tried as well
👍 1