https://kotlinlang.org logo
#compose
Title
# compose
j

John O'Reilly

07/08/2020, 5:08 PM
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

Leland Richardson [G]

07/08/2020, 5:52 PM
can you file bug for this?
j

John O'Reilly

07/08/2020, 7:14 PM
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

Ian Lake

07/09/2020, 12:49 AM
Also, please never use the
<fragment>
tag, use
FragmentContainerView
j

John O'Reilly

07/09/2020, 8:25 AM
I switched it to use
FragmentContainerView
....it doesn't crash now when I show that "screen" again but just does't render map
i

Ian Lake

07/09/2020, 1:34 PM
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

Mahdi

11/05/2020, 2:46 AM
@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

John O'Reilly

11/05/2020, 8:23 AM
@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

Mahdi

11/05/2020, 9:54 AM
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

John O'Reilly

11/05/2020, 9:56 AM
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
2 Views