Ky
02/16/2021, 10:58 PMComponentActivity.setContent
after updating to alpha12?
on alpha11, something like this worked fine
someFrameLayout.setContent(Recomposer.current()) {
CommonMdcTheme {
SomeComposeView(viewModel)
}
}
After updating to alpha 12, it complains about receiver mismatch.
I’ve tried both deprecated method from androidx.compose.ui.platform.setContent
and new method androidx.activity.compose.setContent
manueldidonna
02/16/2021, 11:06 PMKy
02/16/2021, 11:07 PMIan Lake
02/16/2021, 11:10 PMViewGroup.setContent
was replaced with `ComposeView`: https://android-review.googlesource.com/c/platform/frameworks/support/+/1497121val view = ComposeView(context)
view.setContent {
CommonMdcTheme {
// ...
}
}
someFrameLayout.addView(view)
Ky
02/16/2021, 11:16 PMIan Lake
02/16/2021, 11:17 PMRecomposer.current()
itself was completely removed in alpha12: https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.0.0-alpha12 in https://android-review.googlesource.com/c/platform/frameworks/support/+/1544714Ky
02/17/2021, 1:30 AMNullPointerException: Attempt to invoke interface method 'void androidx.compose.runtime.MutableState.setValue(java.lang.Object)' on a null object reference
This happens after calling
class Activity {
fun onCreate() {
val rootView: FrameLayout = findViewById(R.id.rootView)
val composeView = ComposeView(context = this)
Timber.d("Activity: setting view: $view")
view.setContent {
CommonMdcTheme {
CustomComposeView(viewModel)
}
}
rootView.addView(composeView)
}
}
}
From debugging, it hits androidx.compose.ui.platform.Wrapper.kt
and the error is thrown in
internal fun ViewGroup.setContent(
parent: CompositionContext,
content: @Composable () -> Unit
): Composition
Specifically when it calls AndroidComposeView(context).also { addView(it.view, DefaultLayoutParams)
and the context is from my Activity.Ian Lake
02/17/2021, 2:15 AMComponentActivity
or one of its subclasses - and using the latest version of those dependenciesKy
02/17/2021, 2:37 AMMehdi Haghgoo
02/17/2021, 10:53 AMColton Idle
02/28/2021, 4:56 AMNullPointerException: Attempt to invoke interface method 'void androidx.compose.runtime.MutableState.setValue(java.lang.Object)' on a null object reference
I went through and made sure all of my deps are updated as well as my fragment and activity deps. They look fine, but I still get a crash in my fragment. For the heck of it, I changed my Activity to instead setContent { Text("hellow world") } and it worked! This leads me to believe something with fragments isn't working correctly. It builds and install, but crashes at runtime. Any ideas?Ian Lake
02/28/2021, 3:20 PMColton Idle
02/28/2021, 3:25 PMIan Lake
02/28/2021, 3:31 PMColton Idle
02/28/2021, 3:32 PMKy
03/01/2021, 4:04 PM