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

Colton Idle

02/24/2021, 11:18 PM
Can't resolve
setContent
in beta01. Search in slack doesn't show anyone with the same problem. Any ideas?
t

Tash

02/24/2021, 11:19 PM
even with the latest
androidx.activity:activity-compose
?
c

Colton Idle

02/24/2021, 11:19 PM
Whoops!? When did that dependency get added? Never needed it before.
😆 1
t

Tash

02/24/2021, 11:20 PM
Theres a bunch of threads re: this if you scroll up a few days haha. Things were breaking with
alpha12
and
androidx.activity:activity-compose
1.3.0-alpha02
was the cure
Yeah I believe the setContent API for Activity moved over to that artifact
z

Zach Klippenstein (he/him) [MOD]

02/24/2021, 11:21 PM
it moved in alpha12, yep
2
c

Colton Idle

02/24/2021, 11:22 PM
Ah. That's the one I skipped. Moved straight from 11 to beta1. (surprised my slack search failed though. Sorry all)
implementation 'androidx.activity:activity-compose:1.3.0-alpha03'
is a "weird" version no? I guess it's not tied to compose and so that's why latest isn't beta01
👌 1
👍🏼 1
i

Ian Lake

02/24/2021, 11:27 PM
Correct, same as all
-compose
artifacts; they depend on Compose, but are not part of it.
It'll be moving to beta as soon as we get APIs stable (
setContent
isn't going to change though since that was a holdover from its old location)
🙏🏼 1
c

Colton Idle

02/24/2021, 11:31 PM
I've been trying to keep on top of compose, but I guess I missed this one. Thanks all
i

Ian Lake

02/24/2021, 11:33 PM
viewModel()
also moved out to a separate
lifecycle-viewmodel-compose
in case you missed that one as well: https://developer.android.com/jetpack/androidx/releases/lifecycle#lifecycle-viewmodel-compose-1.0.0-alpha02
jetpack compose 3
🙏🏼 3
z

Zach Klippenstein (he/him) [MOD]

02/25/2021, 12:12 AM
oo, does that mean that
AbstractComposeView
doesn’t require a
ViewTreeViewModelStoreOwner
to be present anymore?
👀 1
i

Ian Lake

02/25/2021, 12:16 AM
That is correct.
LocalViewModelStoreOwner
is actually a 'lazily computed' composition local, a pattern used both in
lifecycle-viewmodel-compose
and
activity-compose
for optional composition locals: https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:lifecycl[…]roidx/lifecycle/viewmodel/compose/LocalViewModelStoreOwner.kt
🙏 2
NavHost
does call
LocalViewModelStoreOwner
, so that would be the one composable that has a hard dependency on it existing. Technically, NavController is fine without a
ViewModelStoreOwner
, but the non-null nature of
LocalViewModelStoreOwner
would mean it would go down the
error
route as it is currently written. Filed https://issuetracker.google.com/181173757 to support the usage of
NavHost
without any ViewModels
z

Zach Klippenstein (he/him) [MOD]

02/25/2021, 3:13 PM
Omg yay. I have spent (what feels like) so much of the last month wiring up all the androidx view tree owners into our custom navigation library just so ComposeView works correctly. We don’t use the nav library or view models at all so any less unnecessary work I have to do is very exciting 😅
💯 1
c

Colton Idle

02/25/2021, 3:17 PM
No VMs sounds fun. I guess after having a fully compose app we might do the same.
z

Zach Klippenstein (he/him) [MOD]

02/25/2021, 3:19 PM
We have view models, just not ViewModels 😉
jetpack compose 1
c

Colton Idle

02/25/2021, 3:20 PM
Yeah. Saw that at droidcon ny. Looking forward to just moving to non aac view models. 😬
2 Views