/ SOFTWARE ENGINEERING
2 min read

Boost your project development with Android Jetpack

What is Android Jetpack?

Android Jetpack is a set of libraries, developer tools and architectural guidance to help developers create great applications quick and easy.

Android Jetpack was first announced during Google I/O 2017.

Why it was developed?

Developers tend to always use the help of Android Support libraries, you will stress yourself out if you try to find an application without using something from these dependencies. Support Libraries brought up some confusions to developers, such example is the existence of components and packages named “v4” and “v7” which supports Android version up to API 4 and 7, respectively.

Growing changes from time to time have led Google to realized that it is indeed mystifying for developers on what specific set of versions is needed to be used when starting or maintaining a project.

Android Jetpack was developed in a hope that it will eliminate boilerplate code and simplify intricate tasks while still providing backward compatibility by combining the existing Support libraries and components and wraps them into a new set of components, including the new ones for managing things like navigation, background tasks, and lifecycle management along with UI features like emoji and layout controls for various platforms.

AndroidX, Android KTX

AndroidX

The wrapped set of components lies under the package named androidx. AndroidX fully replaces the Support Library by providing feature parity and new libraries.

Android KTX

Android KTX on the other hand is a set of Kotlin extensions that is part of Android Jetpack. It makes it easier to use Kotlin with Android.

Kotlin
view.viewTreeObserver.addOnPreDrawListener(
    object : ViewTreeObserver.OnPreDrawListener {
        override fun onPreDraw(): Boolean {
            viewTreeObserver.removeOnPreDrawListener(this)
            actionToBeTriggered()
            return true
        }
    }
)
Kotlin + Android KTX
view.doOnPreDraw {
     actionToBeTriggered()
}

Based on the code snippets shown above, you can say that it is more easier to write programs with the help of Android KTX as it removes the boilerplate code developers tend to forget when writing these particular set of codes (especially if they have IDEs with faulty autocompletion!).

Android Jetpack Areas

The Android Jetpack components bring together the existing Support Library and Architecture Components and arrange them into four categories:

alt text Image from https://android-developers.googleblog.com/2018/05/use-android-jetpack-to-accelerate-your.html

Article content to be updated

Source Code

Here is a demonstrable demo app. It is written in Kotlin with AAC + MVVM + Clean Architecture with sample mocking and tests implementation.