8 things to love about the new android development architecture

The android landscape has largely scared web developers for being too difficult to understand. I would confess that have tried to do this thrice. But if you are already a web developer, the sheer complexity of developing mobile apps requires you to have an entirely new mindset.

In this article, I will tell you about my experience in learning android jetpack — a set of libraries and guidelines that make it easier to develop quality android applications.

Android gives you a whole new platform to reach your end-users outside of the web. The web is one open platform where everyone and anyone can develop on the web but this is not the case for android where you are under strict guidelines before you can enter the google app store.


When I finally decided to make an android app for the fourth time. My first go-to stack as like any other web developer was React Native. while this makes a lot of sense as I had quite some experience in React development.

I like project-based learning. So I sat down learning React Native following some youtube tutorials and documentation. But soon I realized that building android apps with React Native is not for serious development and there are a lot of incompatibilities.

The reasons I finally quit on react —

  • Not much support for native android API.
  • React Native applications runs the javascript engine under the hood. which is slow compared to JVM. this can lead to a poor user experience.
  • React Native is not meant for building apps to scale
  • React Native project may get discontinued in the future since naive android development is getting easier.
  • So I tried and gave a shot at developing an android app with Kotlin.

    With recent developments in android app development, a better way to develop android apps has emerged. which closely relates to how web applications are developed. This is called Android Jetpack.

    Android Jetpack is a set of libraries that are provided and maintained by Google and helps in developing elegant android apps and takes out most of the common developer pain points.

    1. Declarative UI using jetpack compose

    This is what I love the most about modern android development. It's fast to code, concise and elegant. There is some learning curve, but it's all worth it in the long term as your coding experience will improve drastically. The jetpack compose is still in the beta phase as of now. But with my first dabble into it I can assure you that it surely going to change how we develop android apps in near future.

    Compose is not the first conceptualization of declarative UI nor the only option on Android ReactLithoVueFlutter, and more.

    Just like how we use React to declare our UI and modularised how we define UI elements and react to data changes well here is Compose that removed our dependency on the XML layout system (the HTML for android). Using compose had been a great experience for me. This allows for reusing the same component in many different places in your app. Compose have made way for infinite possibilities with which we can make new design system, UI frameworks for android, and more. But Compose is not the new player in town. Some other declarative UI libraries like Lithos by Facebook and AsyncUI library by ___. But none of them is production-ready.

    I can bet my money on it. Compose is the Future of UI in android development.

    2. In-app data storage with Room library

    The Room persistence library is an ORM to manage your persistent(in-app) datastorage. Room persistent storage helps you by verifying SQL queries at compile-time. It also has convenience annotations to minimize boilerplate code

    3. Better Performance and reduced app size

    It has been noted that using Compose significantly reduces final apk size.

    Chart Showing apk size of Tivi (refer to the article below)

    When comparing the adjusted values vs ‘Pre-Compose’ we see a reduction in APK size, and reduction in method count when using Compose. - chris banes

    An article by Chris Banes discuss their experience with jetpack compose https://medium.com/androiddevelopers/jetpack-compose-before-and-after-8b43ba0b7d4f

    4. Better backward compatibility with XML

    Compose team has done a great job making it very easy to integrate with the existing android codebase. This is great because if you have an existing android project and want to transition from XML to Compose. It’s going to be a smooth ride. Now we can use XML for some part of the app, fragments on other and Jetpack Components on yet another parts of UI.

    5. Easy State management and LiveData

    LiveData isn’t a new concept just that they are way more improved now. It holds state and updates the state of UI as and when the updated UI is received from the network. These states are managed globally as opposed to React in which we have to use redux with react but in live data, all states are managed globally so there is no concept of redux in android. Taking lessons from reacts ecosystem LiveData was created.

    Photo by Markus Winkler on Unsplash

    6. Separation of Concerns with ViewModel

    Earlier most of the newbie android developers used to define all their frontend logic in the main activity file. With ViewModel, we get modularity in our code and make it easy to debug errors.

    Image by Google android

    7. Reaction to render with side effects

    Sometimes in React when our UI rerenders we want to avoid calling to network or prevent state update this is where we use shouldStateUpdate() in react. Similarly, we can use SideEffects{} in jetpack compose to make network calls and make sure that the code inside SideEffect{} only runs on successful render and not otherwise.

    8. Easy use Navigation that delights us all

    Navigation is a fundamental part of android development. Historically It was done using fragment transaction which for simple cases is easy enough but in the case when you want to do complex navigation like bottom navigation where we have to handle the case of pressing the back button, showing correct fragment.

    The navigation library provides an intuitive easy to use GUI based environment where we can easily define our fragments and activities and connect them using a navigation library with almost no code. This leads to lesser error-prone development and we can focus more on building the app rather than making navigation work.

    Navigation library by Jetpack Compose

    Conclusion

    Not Every programming language is meant to solve everything. This goes for Javascript too this is great for the web but in android, Kotlin makes for a better choice.

    ← Browse More Blog