LightBlog

mardi 8 mai 2018

Android Jetpack is a set of Android components designed with Kotlin in mind, available with Android Studio 3.2

Google’s annual I/O developer conference is where the company unveils their latest tools and features for Android developers, and this year is no exception. Today, the company announced Android Jetpack, a set of components to accelerate app development. Jetpack is designed with Kotlin in mind to help you simplify your code. The latest Android Studio 3.2 canary available today also features new tools for Jetpack.

Accelerating app development with Android Jetpack

Android Jetpack is a set of Android components, tools, and guidance inspired by the backward compatibility of the Support Library and the ease of use of the Android Architecture Components. Jetpack components can broadly be categorized into four categories: Architecture, UI, Foundation, and Behavior.

Architecture components include activities like lifecycle management, ViewModel, data binding, and more. UI components include animation and transitions, fragments, layouts, and more. Foundation components include AppCompat, Multidex, testing, and more. Behavior components include media and playback, permissions, notifications, sharing and more.

Android Jetpack Components

Android Jetpack Components. Source: Google

Components in Jetpack are unbundled libraries, meaning they aren’t a part of the Android platform. This lets you add new components at your own pace as they become available. Furthermore, the components are platform-independent, allowing your app to run on multiple versions of the Android platform.

As you can see in the image above, the new components announced today include WorkManager, Navigation, Paging, Slices, and Android KTX.

WorkManager

This library provides an API for constraint-based background jobs that must be executed, replacing the need for jobs or SyncAdapters. It works on devices without Google Play Services, can create graphs of work, and can query the state of your work.

Navigation

Many applications are composed of multiple activities, but sharing data between activities and implementing transitions has been a pain-point for in-app navigation. The Navigation component will help you structure your in-app user interface as a single-Activity app. It supports Fragments out of the box so all the benefits of Architecture Components such as Lifecycle and ViewModel are there while the Navigation component handles FragmentTransitions for you. Furthermore, you can declare transitions that Navigation will automatically handle, you can build with the correct Up and Back behavior automatically, you can easily provide full support for deep links, and you can connect Navigation to UI widgets like the navigation drawer and bottom navigation. Lastly, the Navigation Editor in the latest Android Studio allows you to visually manage navigation properties.

Android Jetpack Android Studio Kotlin

Navigation Editor in Android Studio 3.2. Source: Google

Paging

The Paging component, when combined with RecyclerView, allows you to add fast, infinite scrolling to your app. The idea is that the component simplifies managing data in pages, ie. pulling chunks of data in succession as quickly as possible and returning results for the user to view.

Slices

Lastly, the Slices component will simplify the process of implementing the Slices API introduced with Android P. It’s an API that lets you surface your app’s UI inside of the Google App as a search result.

Android Slices Android Jetpack

Slices in the Google App. Source: Google

Jetpack—built with Kotlin in mind

At last year’s Google I/O, the company announced that they would be bringing first-class support for the Kotlin programming language to Android Studio 3.0. Kotlin adoption has grown tremendously over the past year—Google states that the number of apps in the Play Store built with Kotlin grew 500% in the last year. With the growing popularity of Kotlin, it makes sense that Android Jetpack was built with the programming language in mind. To that end, Android KTX is launching as a part of Jetpack to help developers simplify their code even further.

The Kotlin developer experience will also see improvements thanks to new code snippets in the official documentation and an API reference documentation page. Google’s Kotlin Bootcamp on Udacity was recently launched as a resource for developers interested in learning the language. Lastly, you can now gain a Kotlin specialization in the Google Developers Experts Program.

Android Studio 3.2 Canary

Android Studio 3.1 was launched at the end of March with the D8 dex compiler, Kotlin Lint checks, and more. The latest Android Studio 3.2 Canary features the visual Navigation Editor mentioned above and new code refactoring tools for Jetpack. To get started building a new app, use te Activity & ViewData activity which you can access from File –> New –> New Project.

Android Studio 3.2 Jetpack

Other improvements include two second start times in the Android Emulator thanks to snapshots, a new R8 Proguard optimizer for smaller app code, and a new Energy Profiler to determine your app’s impact on device battery life.

Conclusion

Android Jetpack will help accelerate app development for many of you who have embraced the Kotlin programming language. Combined with Android KTX and new tools in Android Studio 3.2 Canary, you can get started with the Jetpack components to reduce your code complexity and size.

Google has much more to announce for developers at this year’s I/O. The new App Bundle, Dynamic Delivery, App Actions, and Slices are some of the other new features you should be aware of. Stay tuned to XDA as we bring you the latest news from Google’s annual developer conference.



from xda-developers https://ift.tt/2K2EplR
via IFTTT

Aucun commentaire:

Enregistrer un commentaire