Navigating Jetpack Compose as a Beginner

Navigating Jetpack Compose as a Beginner

Just when I am getting comfortable with Android Development using the Constraint Layout, ViewModel binding and Coroutines, Jetpack Compose beta was released. At this point, we are all aware that the only constant in life is change.

After, looking at some of the videos released by the Android team, it started to make a lot of sense why Jetpack Compose would simplify a lot of things in the current Android development lifecycle. I do not want to go over all the goodies here but the thing I really liked about it, is having the ability to preview your components and making transformations using Kotlin code is a gamechanger to me.

I wanted to go over some of the resources I am currently using to help understand the concepts, build layouts quickly and troubleshoot issues when developing using Jetpack Compose.

Here is a high level overview of what this post covers:

Getting Started

The best place to start learning is using the below resources in the official documentation  provided by the Android team.

Pathway

I would highly recommend going through the pathway at least once before getting started to give you an overview of the all the different capabilities Compose provides to build your app from the start to the end. I regularly go through the different tutorials as I'm rebuilding my app using Jetpack Compose. This helps in understanding improving my understanding every time I go through them.

Setup

Once you are comfortable with the concepts and are now ready to integrate Jetpack Compose into your app, follow the steps described in the Setup guide to best integrate compose into your app. I did run into issues with integrating some of the Jetpack dependencies with the current dependencies and I had to upgrade the versions to resolve it. If you run into issues and not able to resolve it, Google, Medium and  Stack Overflow are your best friends. The community is very active on Stack Overflow and I received a response to my problem in just a few hours and it's my first time posting.

Sample Apps

When we start building our apps, we quickly notice that the documentation or just searching on Google will not give us a detailed implementation of the components. Although the community is quickly picking up on this and we are seeing more and more blogs explaining in detail. We want something where we could look at the sour code, run the app and get a feel for how the implementation looks like.

This is where the samples come in handy. Almost all the common use cases you run through in your development are implemented across these samples. If I am out of ideas this is usually the place I go to find answers, best practices and ideas on how to layout the architecture. My favorite app is the Tivi app as it helped me with a lot of challenges.

One thing I noticed about the samples is that Artic Fox takes up lot of memory when you have multiple projects opened and if you have don't have enough RAM, the system becomes slow. To overcome this I basically open the project folders in VS Code and browse though the code.

Jetpack Compose Guide and Reference

The official Jetpack Compose guide should be our go to for understanding the core concepts. This provides a quick way to navigate through all the relevant topics and provides some good examples of implementation.

Another handy resource would be the Reference Guide provided by Android to look at the different APIs provided and also look at the classes, methods, properties etc. provided on these APIs. For Jetpack Compose I would highly recommend using the Material Compose Reference to look at  implementations provided by the Compose functions.

Using Hilt and Kotlin Flows

If you are new to Dependency Injection, I would highly recommend to start learning it now. Previously I tried Dagger but did not feel like using it. I started again with Hilt and it was easy to understand and use. Having a dependency injection library helps with managing instance creation and testing easy down the lane. Android supports Hilt and Dagger but I just use Hilt for all my scenarios.

Here are some resources I would recommend for learning Hilt

If you are familiar with Coroutines, Flows should be easy to understand and implement. Basically when we use a suspend function with Coroutine we get a single value. But with flows, we can get multiple return values. The power of flows comes in handy when you start leveraging it in the Compose UI with your view models. Here are some useful resources for learning flow.

I plan to keep this post updated with additional resources I find useful along the way. Also there are a lot of hidden gems under each of the above provided resources.

Hope this helps with your Compose journey. Is there anything you hoped to find in here and dint see? Let me know in the comments below and I can plan to update the post.