https://kotlinlang.org logo
Title
d

Derek Alves

03/14/2023, 2:47 PM
hey guys, has anyone worked with Interoperability with Jetpack Compose? I'm using AndroidViewBinding and the app is crashing Error inflating class androidx.fragment.app.FragmentContainerView project: https://github.com/derek-alves/android-nativo/tree/master/meditationui
l

Landry Norris

03/14/2023, 2:52 PM
From the stacktrace, it looks like you don’t have the right constructor. It’s been a minute since I’ve created a custom view/fragment, but if you inflate from XML, there’s a certain few constructors you have to have.
For FragmentContainerView, I think you need to add
androidx.fragment:fragment-ktx
to your dependencies.
d

Derek Alves

03/14/2023, 3:01 PM
Do you have an example of these constructors?
this is the way i am trying to initialize an xml layout
l

Landry Norris

03/14/2023, 3:02 PM
If you’re creating a framework class, such as FragmentContainerView, you just have to add the right dependency. I think it’s fragment-ktx, but could be wrong. The docs should tell you.
d

Derek Alves

03/14/2023, 3:05 PM
ok i will try

these are my dependencies
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
l

Landry Norris

03/14/2023, 3:06 PM
navigation-fragment-ktx is separate from fragment-ktx (confusingly enough). Is the overall project Compose with Views inside or Views with Compose inside?
d

Derek Alves

03/14/2023, 5:01 PM
Compose with Views inside I would like the second tab of BottomNavigation to be an xml screen
@Landry Norris it worked, I just removed the main activity from FragmentContainerView