Gemini Imagen generated: “a paper music partition shredded, piece of paper all over a piano”

10 reasons to NOT use Jetpack Compose

Real use cases where Compose is not a good fit

Cedric Ferry
5 min readSep 24, 2024

--

Introduction

Jetpack Compose is a great UI toolkit that has been warmly welcomed by the android community. It offer a modern way to build delightful UI for your Android App.
I do like Jetpack Compose, but as any technology it comes with some caveats. In this article we are going to learn in what instance it is smarter to use View system and why.

1. Least dependency possible

Compose requires many imports

If you require least dependency possible, it could be for compatibility or security purposes, it can be better to use the View system. The View system doesn’t require extra import. It is inside the Android system unlike Jetpack Compose that requires number of dependencies increasing the package foot print and the memory usage at runtime, and opening the field for additional risks.

2. Performance

The View system has been around since the first version of Android, it is very mature, a lot of optimisation have been done in 15 years and performance is usually better than Jetpack Compose for complex layouts. Jetpack Compose is improving at every iteration and is already sometimes better than View, watch this space, View may soon loose the performance king crown!

3. Espresso tests

Record Espresso Test is not available with Compose

If you have a lot of espresso tests based on View, or if you want to use the test recording feature in Android Studio, it is better avoid using Jetpack Compose or to consider Jetpack Compose only for new screens.
It is not possible to easily migrate View based espresso test to Compose. In addition the Record Espresso Test feature is not available for Compose. However, It is possible to manually write Espresso to test for Compose.

4. Stability and maturity

We touched on that briefly in “performance” section. Jetpack Compose is 3 years young, it improves at every release, but bug may appear from time to time. Additionally a lot of Compose feature are still experimental and require an annotation to opt-in. Using experimental features may be problematic for your business.

// Some feature, like modifier, layout and material design are experimental
// and require to OptIn explicitely
@OptIn(ExperimentalMaterialApi::class)
@OptIn(@ExperimentalFoundationApi::class)
@OptIn(ExperimentalComposeUiApi::class)
@OptIn(ExperimentalLayoutApi::class)

If you require a very high level of maturity and stability, you may want to stick to the View system.

5. Missing features

View system is part of the Android history. A lot of Android feature are available first on View then ported to Compose, often Compose may only provide a wrapper (for example Google Maps). So you may want to keep the View system until these features are available on Compose.
Note that you can to use AndroidView to access those View-only features, Compose will get there eventually.

6. Widely used in existing apps

You will likely have to deal with View in your career. Many big companies still use Views even if they adopt Jetpack Compose. Migrating View-screens to Compose can come with a high price and relatively low value for end customers. Most companies choose to adopt Compose progressively, living older UI using View system. You may need View skill to effectively translate Views to Compose.

7. APK size

in a release build Compose account for 7Mb, it can be totally avoided with View

If you are concerned about the size of your package, you may rethink Jetpack Compose adoption. It will increase your package size by at least a few MB, you can enable R8 full mode to reduce the size further. View system however has a near-zero foot print as the components are part of the system and do not require extra library.

8. Compatibility with older devices

Google Nexus S running Gingerbread 2.3 — API Level 9 / source: CNET website

Jetpack Compose is retro-compatible up to Android API 21 (Lollipop 🍭, Android 5.0). If you want to target previous Android versions, you will have to use View.

9. Embed and IoT devices

Payment terminal using old Android / source: made-in-china.com

Devices that serve a single-purpose (Kiosk, Payment terminal, Self-checkout) often run only one app and have limited resources both CPU and RAM. Jetpack Compose may be too heavy and may require Android developers to use View system to fit the device specifications.
These devices may also run an older version of Android like version 4.0.

10. You don’t feel like learning something new

Maybe you are at the end of your career or want to move to another area, there are situations where learning Jetpack Compose won’t make sense. The learning curve is a bit steep, because it’s a very new approach to UI development compared to View. That said it could be useful to learn as some principles are used in other frameworks, like React and Flutter.

Conclusion

Jetpack Compose is a great UI Toolkit and certainly the future of Android, but it is not the only UI Toolkit and View has demonstrated it work very well, while considered legacy by some, it’s good to pick what fit your needs and constraints. Whatever framework you choose, have fun! Android development is rich and diverse and it’s our role as Android Developers to leverage these strengths.

Thanks for reading this article, I hope you enjoyed and learned something. Please consider clapping 👏🏼 to show your support!

This article is sponsored by Android Developer News, Download the app on the playstore.

--

--

Cedric Ferry
Cedric Ferry

Written by Cedric Ferry

Android Developer @ TikTok, ex-Google

Responses (20)