In 2017, Google IO announced Kotlin as the official language for Android development. In 2018, Google I/O released a series of utilities for Android developers, collectively called Jetpack, to help developers build great Android apps.
What is Jetpack?
Jetpack is a set of libraries, tools, and guides that make it easier for developers to write great applications. These components help you follow best practices, take the work of writing boilerplate code away from you, and simplify complex tasks so you can focus on the code you need. In other words, Google uses Jetpack to standardize some of the best Android component libraries.
Ii. Function:
Android Jetpack is perfectly compatible with The Kotlin language, and with Android KTX you can save a lot of code. Jetpack contains the Androidx.* package library unbundled with the platform API. This means that it provides backward compatibility and updates more frequently than the Android platform, ensuring that you always get the latest and greatest version of the Jetpack component.
- Accelerated development: Components can be adopted separately (though they are built to work together) while leveraging Kotlin language capabilities to help you be more productive.
- Eliminate boilerplate code: Android Jetpack manages tedious activities such as background tasks, navigation, and lifecycle management. So you can focus on how to make your application stand out.
- Build high quality powerful applications: Jetpack components are built around modern design practices and are backward compatible to reduce crashes and memory leaks.
3. What components do Jetpack contain?
The Android Jetpack component covers four areas: Foundation, Architecture, Behavior, and UI.
Foundation
Includes: Android KTX, AppCompat, Auto, Detect, Multidex, Security, Test, TV, Wear OS by Google.
Android KTX
Android KTX is a set of Kotlin extensions that belong to the Android Jetpack series. It optimizes the Jetpack and Android platform apis for Kotlin. Android KTX is designed to let you take advantage of Kotlin language features such as extension functions/properties, lambdas, named parameters, and parameter defaults, and use Kotlin for Android development in a more concise, pleasant, and conventional way. Android KTX does not add any new features to the existing Android API.
AppCompat
Degrade properly on a lower version of Android. AppCompat refers to the V7 AppCompat library. This library adds support for the Action bar user interface design pattern. This library includes support for the Material Design user interface implementation. In other words, we can use this library to achieve more convenient and compatible implementation of Material Design.
Auto
Android Auto provides a standardized interface and user interaction mode for all vehicles. As a designer, you don’t have to worry about vehicle specific hardware differences (such as screen resolution, software interface, knobs, and touch controls).
detection
Quickly benchmark Kotlin – or Java-based code. The library handles the warm-up, measures code performance, and outputs the benchmarking analysis to the Android Studio console. Because these steps involve disabling debugging to get accurate performance results, you do not commit changes to your source control system.
Multidex
If the number of methods exceeds 64K, enable the multi-dex file (65,536 method limit).
Architecture
Include: DataBind, Lifecycles, LiveData, Navigation, Paging, Room, ViewModel, WorkManager.
DataBind
You can use declarative, rather than programmatic, interface components in a layout to bind to data sources in your application. That is, the layout component is bound to the source data so that the layout component can be updated synchronously when the source data changes.
Lifecycles
It is used to manage and respond to changes in the Activity/Fragment lifecycle, helping us write code that is easier to organize and often more lightweight, making it easier to maintain. Lifecycle is a class that holds information about the Lifecycle state of the Activity/Fragment and allows other objects to observe this state.
LiveData
LiveData is an observable data holder class. Unlike regular observables, LiveData is lifecycle aware.
Navigation
This is the interaction that allows users to navigate, enter, and exit different pieces of content in the application. Android Jetpack’s navigation component helps you navigate from simple button clicks to more complex modes such as app bars and draw-out navigation bars. The navigation component also ensures a consistent and predictable user experience by following an established set of principles.
Paging
Step by step to load information on demand from your data source. Paging library.
Room
Room is an ORM abstraction layer framework library for SqlLite provided by Google in order to simplify old style SqlLite operations.
ViewModel
Ui-related data is stored and managed in a lifecycle manner.
WorkManager
Manage tasks that work in the background — even if your application is not started. For example, sending log analysis to the back-end service periodically synchronizes application data with the server