7 Annoying Things About Jetpack Compose According to Me | by sinasamaki | Apr, 2022

Jetpack Compose is arguably some of the thrilling improvements on this planet of Android growth. It’s been a breath of recent air from the growing older XML UI system and has introduced quite a few enhancements.

On prime of that, the speed of its growth can also be staggering. It’s been nearly a 12 months because it went secure and is being adopted by varied groups. However not the whole lot is ideal. Jetpack compose nonetheless has some areas that aren’t absolutely mature or not but developed. On this article, I’ll go over some annoying bugs and lacking options that I’ve personally encountered whereas working full-time migrating a legacy app to compose and a few facet tasks of my very own.

In Android studio, we are able to arrange previews with a purpose to see the designs we’re implementing in compose. However this preview is a far cry from the outdated XML preview, by way of efficiency. Modifications should not immediately seen on display screen and require a rebuild to see them. However with time, the compose preview will get there and doubtless surpass the XML preview. There have been latest updates to allow interactivity and likewise preview animations.

Relying on whenever you began utilizing compose, you’d have discovered little or no UI libraries in comparison with what we’re usually used to. I’ve ended up creating customized options for some widespread issues (On the brilliant facet, this gave me extra expertise writing composables). That is after all anticipated since compose remains to be comparatively younger.

Efficiency is a really essential a part of an app, and it’s our job as builders to take care of a clean expertise for our customers. Sadly, we cannot accomplish that with out correct instruments to debug efficiency. We nonetheless have entry to the instruments we had for debugging the outdated XML UI, however I’d argue we want new instruments and programs for compose’s declarative system. In my expertise, most UI lag in compose has been brought on by a misunderstanding of how state works, ending up in a number of pointless recompositions. The Google Play staff additionally realized this and constructed a custom modifier for monitoring recompositions as they had been optimizing. Instruments like this must be made extra accessible, proper into compose. There can be warnings in Android Studio to keep away from widespread antipatterns that result in UI lag.

Most apps depend on commercials for income. So likelihood is that you’d have to implement advertisements in your app in a technique or one other. However in case you are utilizing compose in your app, it’s possible you’ll run into some situations when you would need to swap to XML views. Advert libraries should not but accessible natively in jetpack compose. This turns into a problem, particularly with native advertisements, whenever you outline the textual content components of the advert in xml however nonetheless have to match it with the design from the compose theme. The AndroidView does provide actually nice interoperability, however I feel that’s only a stepping stone to bridge the 2 worlds for now. For a terrific expertise, advert libraries ought to provide composable variations of their advert containers.

Any app with multiple display screen positively wants a system to handle navigation via the app. Jetpack navigation is the formally really helpful manner, but it has a bizarre bug that’s arduous to miss. There’s a fade animation between screens, and this isn’t configurable and cannot be turned off. There may be one other issue monitoring when animations will likely be added whereas navigation, however as for now, you might use Accompanists navigation library and tweak or flip off the animation.

Gone are the times of writing adapters and ViewHolders for a RecyclerView. Now we have now LazyLists that we are able to create in seconds. However by way of animation, It cannot nonetheless match as much as the RecyclerView. There have been some updates including reordering animations (though there have been some issues reported on that), however there nonetheless just isn’t an official implementation for including and eradicating animations. I’ve been utilizing this solution in my apps till there may be an official and secure implementation.

This final one looks like a small one however has a big effect on how customers understand the app. Nested scrolling is a standard constructing block in some UI patterns. Whether or not it’s a collapsing app bar or a modal with a listing in it, there are quite a few makes use of for it. In these circumstances, scrolling efficiency must be reactive and clean. Failure of which, the app may really feel janky or not native. The fling bug offers unsuitable velocity values whereas scrolling, which causes the checklist to cease scrolling immediately and even begin scrolling within the unsuitable route.

These are 7 annoying issues have encountered whereas migrating to compose. If you want to share in my frustration, or you will have discovered a correct answer to any of those points, please let me know

Thanks for studying and good luck!

More Posts