[요약] Google I/O 2022 What’s new in Jetpack

seong-hwan Kim
shDev
Published in
4 min readMay 15, 2022

Jetpack Overview

2021년 상위 1000개의 앱 중 79%가 2개 이상의 Jetpack 라이브러리를 사용하였고, 2022년에는 90% 이상의 앱에서 2개 이상의 Jetpack 라이브러리를 사용중이다.

Architecture

Room

stable: androidx.room:room:2.4.2

Database persistence layer designed for usability, safety, and testability

  • 2.4.0에서 KSP를 지원
  • 코틀린 1.6 지원
  • 2.5.0부터 전체 소스가 코틀린으로 재작성될 예정
  • androidx.room:room-paging을 통해 Paging 3.0을 지원 → Room 쿼리가 Paging source object를 리턴할 수 있다.

Room에서 리턴 타입을 Map으로 지정하여 relational query method를 사용할 수 있다. 따라서 추가적인 자료구조를 정의하지 않고도 JOIN 쿼리를 사용할 수 있다.

@Database 어노테이션에서 autoMigrations 프로퍼티를 통해 버전 별 쉬운 마이그레이션이 가능하다. 마이그레이션을 위해 추가적인 정보가 필요하다면 @AutoMigration 어노테이션을 사용한다.

Paging

stable: androidx.paging:paging:3.1.1

Load and display small chunks of data to improve network and system resource consumption

  • 자바에서 코루틴의 대안으로 사용할 수 있도록 Paging 3.1에서 Rx와 Guava를 지원
  • LoadResult.Invalid 리턴 타입을 통해 invalid or stale data를 효과적으로 처리
  • onPagesPresented, addOnPagesUpdatedListener 등의 API가 추가됨
  • Paging 3를 다루은 코드랩 추가

Navigation

stable: androidx.navigation:navigation:2.4.1

Framework for navigating between destinations within an app, now with multiple backstacks

  • Navigation Compose가 Navigation component와 Jetpack Compose를 통합
  • 기존에 사용하는 코드의 변경 없이 Navigation UI가 자동으로 백스택을 저장하고 복구
  • two-pane layout으로 대형 화면 내비게이션 지원
  • 전체 소스를 코틀린으로 재작성

DataStore

stable: androidx.datasotre:datastore:1.0.0

Data storage solution that provides a simple, rodust alternative to SharedPreferences

  • DataStore에 대한 MAD Skills 제공

Architecture

  • Architecture에 대한 MAD Skills 제공
  • Modern Android Development의 best practice를 소개

Performance

JankStats

alpha: androidx.metrics:metrics-performance

Track and analyze jank performance problems in your app’s UI

  • API 16 까지 호환 가능
  • internal heuristics를 사용하여 퍼포먼스 이슈를 식별
  • Provides UI context to attribute data to user states and actions
  • 리스너를 사용해 각각의 프레임에 대한 분석 결과를 제공

Baseline Profiles

stable: androidx.profileinstaller:profileinstaller:1.1.0

Create profiles for your app that prepopilate ahead of time compilation traces to reduce startup times and reduce jank

  • Provide custom profile rules in apps and libraries
  • Startup and jank performance improvements
  • Profiles added to popular Jetpack libraries

Fragment와 Compose등의 라이브러리에서 이미 Baseline Profiles를 적용하고 있다.

custom profile을 생성하려면 Macrobenchmark를 사용한다.

Macrobenchmark

stable: androidx.benchmark:benchmark-macro:1.1.0

Accurately measure app startup and scrolling performance, both locally and in CI

  • API 23 까지 호환 가능
  • TraceSectionMetric을 사용한 custom trace-based timing measurements 기능 추가
  • AudioUnderrunMetric을 사용하면 audible jank 확인 가능
  • BaselineProfileRule을 사용하여 profile 생성 가능

Tracing

stable: androidx.tracing:tracing:1.1.0

Write trace events to the system trace buffer

UI

WindowManager

stable: androidx.window:window:1.1.0

Support new device form factors and multi-window environments

  • 폴더블 기기에서 컨텐트 표시를 지원
  • Smart layout avoids placing content in occluded areas
  • Already intergrated into SlidingPaneLayout

DragAndDrop

alpha: androidx.draganddrop:draganddrop

Accepts drag-and-drop data with a consistent user experience

  • API 24 까지 호환 가능

AppCompat

alpha: androidx.appcompat:appcompat

Access the latest foundational UI features from earlier API levels

  • 1.8 에서 AppCompat과 Emoji2를 통합
  • API 14 to 33 에서 Custom locale selection 을 지원
  • Play splits를 사용하여 추가적인 locale을 다운로드 가능 (1.9 alpha)

Compose

1.2 beta

정식 버전이 공개된지 몇 개월 지나지 않았지만 상위 1000개의 앱 중 100개 이상의 앱에서 컴포즈를 사용중이다.

Google play, Twitter, Airbnb에서 Compose를 사용중.

Nested Scrolling Interop

뷰 시스템과 컴포즈 사이의 상호 운용성이 강화되었다.

예를 들어, 컴포즈 1.2에서는 CoordinatorLayout 내에서 scollable composable이 더욱 매끄럽게 동작하며, CollapsingToolbar를 쉽게 설정할 수 있다.

Downloadable Fonts

앱에 포함되는 폰트는 APK 사이즈를 키울 수 있다. 컴포즈 1.2 에서는 downloadable font를 제공한다.

Lazy Layouts

LazyRow, LazyColumn 외에도 LazyGrid 또는 커스텀 레이아웃을 LazyList로 표현할 수 있다.

자세한 내용은 Lazy Layouts in Compose 세션을 참고 바람.

Tools

자세한 내용은 What’s New in Android Studio 참고.

Live Edit, Recomposition debugging, Compose Animation Preview 등의 기능을 제공한다.

Advanced Composing

I/O talks

I/O workshops

Resources

  • New Custom Design Systems codelab
  • New docs on Performance and Input

Android Basics with Compose (g.co/android/basices-compose)

Compose across all UI

I/O talks

Other Announcements and Additional Talks

Annotation

stable: androidx.annotation

Expose metadata that helps tools and other developers understand your app’s code

  • 소스를 코틀린으로 변경
  • @ReturnThis ensures overrides return this
  • @OpenForTesting limits subclassing or override to test code
  • @EmptySuper prevents override calls to superclass implementations
  • @DeprecatedSinceApi discourages calls at or above the given API level

Other I/O talks

--

--