jetc.dev Newsletter Issue #26
This week, most of the focus is on the
dev16 release, both in terms of the
big changes (totally revised Java packages) and the smaller ones. Plus,
we try to think declaratively, look at Joe Birch’s latest Compose app, and
just try to “roll with the (Compose) changes”.
One Off the Stack, One Off the Slack
You’ve got questions. That’s understandable!
Alas, we continue to collect few good answers in Stack Overflow in
Android developers are very used to “to change what the user sees, manipulate properties of objects”. Compose and declarative UIs instead go with “to change what the user sees, describe what you want to show now”. This is more powerful and, in the end, less complex, but it is a change in mindset, as we see in this week’s highlighted Slack thread.
Posts, videos, and other new information related to Jetpack Compose!
dev15 was about changing artifacts.
dev16 is about changing Java packages.
Most of your imports will need to be switched. A table appears in the release
notes, and all of the new packages are sub-packages of
androidx.ui.tooling are left alone, as their artifacts
savedInstanceStateOf() now use
== instead of
=== to determine when values have changed, by default.
policy = referentialEqualityPolicy() in those functions to switch
Names keep changing: what was
LazyColumnItems, is now
LazyColumnFor. We also have
LazyColumnForIndexed to give us an index number
along with each item in the callback, plus
Row equivalents (
Modifier.drawBackground() is now
Column are now inline functions, and
ConstraintSet2 is now called
ConstraintSet. And more!
Activity are now deprecated in favor of
FocusManager has been deprecated in favor of modifiers like
Modifier.tag() is deprecated in favor of
is deprecated (along with the
+ operator) in favor of
ColorPalette is now
Colors and is a final class, and its focus is tightened to
being just a definition of material colors, not a general-purpose theme engine.
TextField is now called
FilledTextField takes over
Wajahat Karim’s 360|AnDev presentation video is up; Issue #24 had links to the slides. As the title suggests, this is a codelab walking you through setting up Compose and making a basic app.
100% pure code!
Joe Birch returns with Minimise, “to help us think more about the purchases we make and rediscover the things that we own”. This is a Kotlin/Multiplatform app, with Android and iOS UIs, the former implemented using Compose.
GitHub user MFranceschi6 offers a Compose modifier that adds an animated loading spinner to the composable of your choice, with a simple boolean state to control when the spinner should be replaced by the real content.
…And One More Thing
dev16 represents the last of the “refactor the world” developer
dev15 switched the artifacts;
dev16 switched the Java
packages. So while last time you needed to fix your Gradle build scripts,
this time you just need to reimport everything.
dev16 release notes
offers a cheat sheet of all the Java packages, set up as
In theory, you can replace all the broken ones with this list, then let
Android Studio optimize the imports. Just do that for every source file.
Once again, “just”.
This sort of change might not have been inevitable, but it seems perfectly reasonable. Compose is huge, and it would have been unrealistic to expect its developers to get the packaging correct the first time. Conversely, this sort of wide-ranging set of moves gets more painful as we move into alpha/beta/RC/stable releases, so this is a good time to get it out of the way.
The downside, as with all of these sorts of things, is making existing educational material moderately obsolete. Questions like this one exemplify the problem: developers trying to play with Compose run into out-of-date posts and stuff. Now, that just got a lot worse… temporarily. In the fullness of time, we will have new articles, posts, videos, projects, and answers to replace the obsolete ones. And, that is a key reason why it is good that these changes are out of the way, so by the time alpha releases arrive, we have a (hopefully) stable packaging of Compose.
So, everything will be wonderful in time. We just have to wait for the future to get here.
If you encounter problems in subscribing, let us know!