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

Shivam Sethi

02/27/2021, 8:13 AM
Anybody know how can I add compose to existing codebase, I want to add it to a new fragment without any XML, I tried to follow Interop documentation but after doing the steps, the build was successful app launched and crashed when I navigated to that fragment, it only had a ComposeView with a Text.
t

TheMrCodes

02/27/2021, 9:50 AM
Please remove the Stacktrace from your initial comment and add it to the thread as a reply Thanks
☝️ 4
a

Adam Powell

02/27/2021, 2:37 PM
Also please file a bug on the issue tracker, this looks like a bug in compose UI itself.
s

Shivam Sethi

02/27/2021, 4:28 PM
Sorry, for the inconvenience. Following is the stack trace I got Attempt to invoke interface method 'void androidx.compose.runtime.MutableState.setValue(java.lang.Object)' on a null object reference at androidx.compose.ui.platform.AndroidComposeView.setLayoutDirection(AndroidComposeView.android.kt:930) at androidx.compose.ui.platform.AndroidComposeView.onRtlPropertiesChanged(AndroidComposeView.android.kt:768) at android.view.View.resolvePadding(View.java:20272) at android.view.ViewGroup.resolvePadding(ViewGroup.java:7765) at android.view.View.initializeScrollbarsInternal(View.java:6781) at android.view.View.<init>(View.java:6112) at android.view.ViewGroup.<init>(ViewGroup.java:697) at android.view.ViewGroup.<init>(ViewGroup.java:693) at android.view.ViewGroup.<init>(ViewGroup.java:689) at android.view.ViewGroup.<init>(ViewGroup.java:685) at androidx.compose.ui.platform.AndroidComposeView.<init>(AndroidComposeView.android.kt:115) at androidx.compose.ui.platform.Wrapper_androidKt.setContent(Wrapper.android.kt:79) at androidx.compose.ui.platform.AbstractComposeView.ensureCompositionCreated(ComposeView.android.kt:175) at androidx.compose.ui.platform.AbstractComposeView.onAttachedToWindow(ComposeView.android.kt:207) at android.view.View.dispatchAttachedToWindow(View.java:20479) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3489) at android.view.ViewGroup.addViewInner(ViewGroup.java:5278) at android.view.ViewGroup.addView(ViewGroup.java:5064) at androidx.fragment.app.FragmentContainerView.addView(FragmentContainerView.java:290) at android.view.ViewGroup.addView(ViewGroup.java:5004) at androidx.fragment.app.FragmentStateManager.addViewToContainer(FragmentStateManager.java:830) at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:520) at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:282) at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:2177) at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:2094) at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1990) at androidx.fragment.app.FragmentManager$5.run(FragmentManager.java:524) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:223) at android.app.ActivityThread.main(ActivityThread.java:7660) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
👍 1
c

Colton Idle

02/28/2021, 4:40 AM
@Shivam Sethi do you happen to use buildSrc or build.gradle.kts?
s

Shivam Sethi

02/28/2021, 6:35 AM
thanks for a response, I am using the normal build gradle, not Kotlin dsl
After researching, I suspect this is because I am using data binding in build features in project, can this be solved any way I do not want to remove data binding as it's used in almost every XML
c

Colton Idle

02/28/2021, 7:27 PM
Hm. I don't use data binding. I wonder if you can make a small sample app with data binding to repro.
@Shivam Sethi filed this bug as its similar to yours you may wish to star it. https://issuetracker.google.com/issues/181463117
s

Shivam Sethi

02/28/2021, 11:59 PM
I tried making a sample app which uses data binding in one fragment and compose in another in same app module and it worked there, so now I am not sure what might me causing this error?
c

Colton Idle

03/01/2021, 12:08 AM
Ah. That's great news! Maybe you could comment on the issuetracker ticket and say that just to loop in whoever takes a look?
s

Shivam Sethi

03/01/2021, 1:30 AM
Sure, I guess I should remove issue that I reported as https://issuetracker.google.com/issues/181463117 this is in much detail and have exact problem
c

Colton Idle

03/01/2021, 2:07 AM
Thanks! Hopefully we can all help the android team get to a solution.
a

Adam Powell

03/01/2021, 2:10 AM
The stack trace from the beginning of the thread is enough info to fix the problem. Views have an annoying history of calling non-final methods either directly or transitively in their constructors and this hit one of those code paths. Should be an easy fix once someone sits down with it.
😍 2
s

Shivam Sethi

03/01/2021, 2:12 AM
@Adam Powell thanks for the heads up.
👍 1
a

Adam Powell

03/02/2021, 1:10 AM
s

Shivam Sethi

03/02/2021, 5:58 AM
Thank-you Android team🙌
c

Colton Idle

03/02/2021, 2:10 PM
Thanks Adam Powell I know it's probably to early to really say, but how does the release train for these things look. Is there a chance it'll make it into beta02?
🤔 1
a

Adam Powell

03/02/2021, 2:54 PM
It should be in the build cut for tomorrow and go out a week after that if everything goes smoothly
K 1