What exactly is Android Jetpack?

AndroidAndroid Jetpack

Android Problem Overview


I've seen the developer keynote of Google I/O 2018, and I've read the jetpack homepage on Android developer website, but I cannot make sense of what it actually is. To me it seems like just a new name for a bunch of APIs we already use. Is there going to be something that the IDE does for us or something that's helpful while coding? All the components in Jetpack point to their original Android documentation, and don't actually showcase any difference than before. Can someone explain in simple terms what Jetpack actually does for me as a developer, apart from clubbing documentation on a web page?

Android Solutions


Solution 1 - Android

On its official site, it says:

> Android Jetpack is a set of libraries, tools and architectural guidance to help make it quick and easy to build great Android apps. It provides common infrastructure code so you can focus on what makes your app unique

Technically, it is the support library, android-ktx and the Android Architecture Components re-branded as a single modular "entity".

This is why all non-Android extension libraries like support, etc. are re-packaged to androidx.**.

> Quote from Alan Viverette (from Android Framework Team): > > Jetpack is a larger-scoped effort to improve developer experience, but AndroidX forms the technical foundation. From a technical perspective, it's still the same libraries you'd have seen under Support Library and Architecture Components. > > As best practices change, you may also see libraries in the androidx.* package that are not included in Jetpack.

See https://developer.android.com/topic/libraries/support-library/refactor for more info.

Solution 2 - Android

Basically it is just set of useful things combined and sorted under 4 categories

> Foundation > > Architecture > > Behavior > > UI

Some of the core things like AppCompat library, Architecture components, Fragments, Animation and transitions and many more were added now in relative categories and these 5 things were newly added.

  1. Android Ktx

The purpose of Android KTX is to make Android development with Kotlin more concise, pleasant, and idiomatic by leveraging Kotlin language features such as extension functions/properties, lambdas, named parameters, and parameter default values

  1. Navigation

The Navigation Architecture Component simplifies the implementation of navigation in an Android app.This is related to implementing a clear flow in your app. Here in this video you can find a very nice explanation about this topic.

  1. Paging

The Paging Library makes it easier for you to load data gradually and gracefully within your app's RecyclerView. Here is the I/O talk from Yigit Boyar, It's very well explained by him.

  1. Slices

Slices are UI templates that can display rich, dynamic, and interactive content from your app from within the Google Search app and later in other places like the Google Assistant. Slices can help users perform tasks faster by enabling engagement outside of the full screen app experience. You can build Slices as enhancements to App Actions. Learn more from this talk

  1. WorkManager [ I personally recommend you to check this thing out ]

You can gracefully schedule tasks with WorkManager.The WorkManager API makes it easy to specify deferrable, asynchronous tasks and when they should run. These APIs let you create a task and hand it off to WorkManager to run immediately or at an appropriate time. This Video explains it in depth.

I have created a playlist Here. It consists all best videos related to Jetpack, Hope this helps.

Solution 3 - Android

Android Jetpack is a collection of Android software components which helps us in building great Android apps.

These software components help in:

  • Following the best practices and writing the boilerplate code.
  • Making complex things very simple.

Earlier there were many challenges which are as follows:

  • Managing activity lifecycles.
  • Surviving configuration changes.
  • Preventing memory leaks.

All these major problems have been solved by the Android Jetpack's software components.

So, the solution for all the problems is Andriod Jetpack.

Another most important thing about the Jetpack is that it gets updated more frequently than the Android platform so that we always get the latest version.

Jetpack comprises the androidx.* package libraries, unbundled from the platform APIs. This means that it offers backward compatibility.

Android Jetpack Components

Android Jetpack components are a collection of libraries that are individually adoptable and built to work together while taking advantage of Kotlin language features that make us more productive.

These software components have been arranged in 4 categories which are as follows:

  • Foundation Components
  • Architecture Components
  • Behavior Components
  • UI Components

Let's see one by one.

Foundation Components

The foundation components provide the following:

  • Backward compatibility
  • Testing
  • Kotlin language support.

All the foundation components are as follows:

  • App Compat
  • Android KTX
  • Multidex
  • Test

Architecture Components

The architecture components help us in building:

  • Robust Apps
  • Testable Apps
  • Maintainable Apps

All the architecture components are as follows:

  • Data Binding
  • Lifecycles
  • LiveData
  • Navigation
  • Paging
  • Room
  • ViewModel
  • WorkManager

Behavior Components

The behavior components help in the integration with standard Android services like

  • Notifications
  • Permissions
  • Sharing
  • Assistant

All the behavior components are as follows:

  • Download Manager
  • Media & playback
  • Notifications
  • Permissions
  • Preferences
  • Sharing
  • Slices

UI Components

The UI components provide widgets and helpers to make your app not only easy, but delightful to use.

All the UI components are as follows:

  • Animation and transitions
  • Auto
  • Emoji
  • Fragment
  • Layout
  • Palette
  • TV
  • Wear

Reference article

Solution 4 - Android

From the blog:

>Android Jetpack is the next generation of Android components, bringing together the benefits of the Support Library -- backwards compatibility and immediate updates -- to a larger set of components, making it quick and easy to build robust, high quality apps. Android Jetpack manages activities like background tasks, navigation, and lifecycle management, so you can eliminate boilerplate code and focus on what makes your app great. Android Jetpack is designed to work well with Kotlin, saving you even more code with Android KTX. The new Android Jetpack components released today include WorkManager, Paging, Navigation, and Slices.

From official doc:

>Android Jetpack is a set of libraries, developer tools and architectural guidance to help make it quick and easy to build great Android apps. It provides common infrastructure code so you can focus on what makes your app unique.

enter image description here

Solution 5 - Android

Android Jetpack Components

Android Jetpack components are a collection of libraries that are individually adoptable and built to work together while taking advantage of Kotlin language features that make us more productive.

These software components have been arranged in 4 categories which are as follows:

  • Foundation Components
  • Architecture Components
  • Behavior Components
  • UI Components

Architecture Components

All the architecture components are as follows:

  • Data Binding: Declaratively bind UI elements to in our layout to data sources of our app.
  • Lifecycles: Manages activity and fragment lifecycles of our app.
  • LiveData: Notify views of any database changes.
  • Navigation: Handle everything needed for in-app navigation.
  • Paging: Gradually load information on demand from your data source.
  • Room: Fluent SQLite database access.
  • ViewModel: Manage UI-related data in a lifecycle-conscious way.
  • WorkManager: Manage every background jobs in Android with the circumstances we choose.

For more details use below link:- https://blog.mindorks.com/what-is-android-jetpack-and-why-should-we-use-it

Solution 6 - Android

As we all are quoting the official site and it says,

> Android Jetpack provides a series of unbundled libraries not tied to any particular version of Android, giving developers a way to support newer features on older versions of the Android operating system. In addition to backward compatibility, Jetpack promises to help you get more done, with less code, by providing the boilerplate to handle repetitive tasks like managing the application lifecycle.

So now let's break this into bits and pieces, it simply says 2 things

  1. So, all the libraries that come under Jetpack are independent of each other. You can update any particular library without updating others at the same time. You remember those warning,

> Those frustrating “All com.android.support libraries must use the exact same version specification” messages should become a thing of the past now.

But that is when you use Androidx libraries and not Support ones.

  1. Now all these libraries that come under Jetpack do a lot of boilerplate code at their side, so you don't need to write a lot of code and just worry about the logic. Ex - Remember handling Screen Rotation? (ViewModel takes care of it), Handling infinite scrolling by pagination? (now you have Paging library for that), handling back buttons (Navigation library is there for you), handling dependency injection manually or using Dagger (Hilt is your friend here), handling different use-cases of Camera and still fixing bugs in production ( CameraX is an easy way going) (just a few of those)

There are other reasons too to put out JetPack separately, let's discuss those too..

  1. Initially, the name of each package indicated the minimum API level supported by that package, for example, support-v4. However, version 26.0.0 of the Support Library increased the minimum API to 14, so today many of the package names have nothing to do with the minimum supported API level. When support-v4 and the support-v7 packages both have a minimum API of 14, it’s easy to see why people get confused!. So now with AndroidX, this confusion disappears.

  2. With the current naming convention (support ones), it also isn’t clear which packages are bundled with the Android operating system, and which are packaged with your application’s APK (Android Package Kit). To clear up this confusion, all the unbundled libraries will be moved to AndroidX’s androidx.* namespace, while the android.* package hierarchy will be reserved for packages that ship with the Android operating system. Simply saying, now on, android.* will be reserved for android operating system related packages, so these packages will anyway start with android.* package name WHILE androidx.* will now be reserved for app development related stuff.

  3. Apart from this, you have:

  • Architectural Component
  • Foundational Component
  • UI component
  • Behaviour Component

So now, Jetpack is nothing but a name given to the superset of these components, androidx and other tools.

Solution 7 - Android

Android Jetpack is a set of libraries that helps you to deal with the challenges you eventually face as a Android Developer — writing boilerplate code, managing activity lifecycles, surviving configuration changes or preventing memory leaks.

Jetpack libraries may be used alone or in combination to address different needs in your apps.

  • WorkManager for your background scheduling needs.
  • Room for data storage persistence.
  • Navigation to manage your application navigation flow.
  • CameraX for your camera app needs.

Solution 8 - Android

Android Jetpack is a collection of Android software components which helps us in building great Android apps. Android Jetpack Components are a collection of libraries ,tools that help in developing robust android applications. Jetpack comprises the androidx.* package libraries, unbundled from the platform APIs. This means that it offers backward compatibility. The software components have been divided into 4 categories:

  • Foundation Components
  • Architecture Components
  • Behaviour Components
  • UI Components

> Foundation Components - Foundation Components provide Backward compatibility, Testing, Kotlin support.

Foundation Components are:

  • App Compat: The AppCompat library in Jetpack foundation includes all of the components from the v7 library. This includes AppCompat, Cardview, GridLayout, MediaRouter, Palette, RecyclerView, Renderscript, Preferences, Leanback, Vector Drawable, Design, Custom tabs, etc. Moreover, this library provides implementation support to the material design user interface which makes AppCompat very useful for the developers.
  • Android KTX: KTX stands for Kotlin Extensions ,Android KTX consists of a set of Kotlin extensions that are designed to facilitate developers to remove boilerplate code as well as to write concise code while developing android applications with Kotlin language.
  • Multidex: Dex is the format of the executable file which runs on the Android virtual machine(known as Dalvik). Multidex component also provides support to the collective dex files of an application.
  • Test: includes the Espresso UI testing framework for the runtime UI test and AndroidJUnitRunner for the purpose of unit testing of Android applications.

> Architecture Componets helps in building robust apps.It does not support any particular architecture pattern but suggests clear separation of concerns and controlling of UI from Model by which developers can avoid problems related to activity lifecycle.

Architecture components are:

  • Room-The Room component acts as an SQLite Object Mapping Library which overcomes challenges from using SQLite like checking the queries at compile-time, writing boiler plate code. Room converts queries directly into objects, check errors in queries at the compile-time, and is also capable of persisting the Java POJOs. Sub components are:

    1.Entity

    2.Data Access Object

    3.Database

  • WorkManager-manage the background tasks in Android which are deferrable(can be run later and is still useful) as well as guaranteed(runs even if the device restarts). It Provides backward compatibility,Scheduling and chaining of tasks is possible ,Users can keep track of/status of the tasks.

  • LifeCycles-The androidx.lifecycle package components perform actions in response to a change in the lifecycle status of another component, such as activities and fragments. These components help you produce better-organized, and often lighter-weight code, that is easier to maintain.This helps in creating organized application components, ease in testing and maintenance of components, less code requirement to executes tasks.

  • ViewModel-Manage UI-related data in a lifecycle-conscious way. It helps in data management during configuration changes ,Reduce UI bugs and crashes.

  • LiveData- Livedata notify the UI of any appropriate change in the data. If the observer’s lifecycle state is destroyed, LiveData is capable to remove it, and thus it avoids memory leaks. It removes the stopped or destroyed activities which reduce the chance of app crash.

  • Navigation Component-Navigation Component get all the benefits of other Architecture components as well like Lifecycle and ViewModel. It helps in implementing basic navigation styles like simple button clicks to complex navigation patterns like app bar and navigation drawer.Further, it also supports deep links and helpers which enables the connection of this component with the navigation drawer and bottom navigation. It ease the transition through animated visualization,s upports deep linking, handle fragment transactions, support common as well as a complex navigation pattern

  • Paging- This library provides the facility to load the application data slowly and in a cautious manner. Easy to integrate with Recycler View in order to display a large data set, compatible with LiveData and RxJava for updating the UI data, loads data gradually with caution.

  • Data Binding- Data Binding library is a support library that provides the feature of binding UI components in an activity/fragment to the data sources of the application. Make code simpler and easy to maintain by removing UI frameworks called in the activity.It also Allows classes and methods to observe changes in data and allows to make objects and filled which works as collection observable.

> Behaviour Components- Behavior components help in the integration with standard Android services like Notifications,Permissions,Sharing,Assistant.

Behaviour Components are:

  • Download Manager : The DownloadManager is a system service in Android that helps in downloading bulky files in the background thread.It Schedule and manage large downloads in background with auto retry support.
  • Media & playback:Jetpack provides a backward-compatible API for the Android multimedia framework. The included Media libraries facilitate developers to integrate audio, video, and image files into an application Backwards compatible APIs for media playback and routing (including Google Cast).
  • Notifications: Provides a backwards-compatible notification API with Wear and Auto support.
  • Permissions: Compatibility APIs for checking and requesting permissions in app.
  • Preferences: Create interactive settings screens for users to configure.
  • Sharing: Provides a share action suitable for an app’s action bar.The ShareActionProvider class is used to carry out the task of sharing contents and information.
  • Slices: Create flexible UI elements that can display app data outside the app and can be extended all the way back to Android 4.4.

> UI Components-The UI components provide widgets and helpers that aim to improve the interactions that users have with Android applications.

UI Components are:

  • Animation and transitions: Jetpack offers APIs to set up different kinds of animations available for Android apps.This framework imparts the ability to move widgets as well as switching between screens with animation and transition in an application.

  • Auto: Components to develop Android Auto apps.The following category of applications can be built, test, and distributed on Android Auto: Navigation apps,Messaging apps,Media apps.

  • Emoji: Enable updated emoji font on older platforms. Google has released new library called EmojiCompat in order to handle emoji characters and to use downloadable font support.The backward compatibility of this library is up to Android 4.4(API level 19).

  • Fragment: Represents a behaviour or portion of the user interface, used for dynamic and flexible UI designs (and to reduce boilerplate layouts and code).

  • Layout: Are used for creating and designing the structure of the user interface.

  • Palette: Used for designing layout themes and to apply custom colors to the elements of the app.

  • TV: Components to develop Android TV apps.

  • Wear: Components created to help develop apps for Wear.

Solution 9 - Android

Android Jetpack is a set of libraries which makes life of android developers easy. Android development can be done without jetpack also, but it gives your applications more modular, application life-cycle aware and more testable.

For instance, Work manager is a Jetpack component which is used for scheduling tasks for may get triggered when suitable conditions meet (like device is plugged in). Applications can be developed without using Workmanager also (Using Jobschedular), but developer will not have more options.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionishaanView Question on Stackoverflow
Solution 1 - AndroidEpicPandaForceView Answer on Stackoverflow
Solution 2 - AndroidTapanHPView Answer on Stackoverflow
Solution 3 - AndroidAmit ShekharView Answer on Stackoverflow
Solution 4 - AndroidGabriele MariottiView Answer on Stackoverflow
Solution 5 - AndroidAbhishek DubeyView Answer on Stackoverflow
Solution 6 - AndroidAbhishek KumarView Answer on Stackoverflow
Solution 7 - AndroidShubham PawarView Answer on Stackoverflow
Solution 8 - AndroidAndroid_idView Answer on Stackoverflow
Solution 9 - Androidranvir singhView Answer on Stackoverflow