Google I/O 2021 Recap: Dev Tools & Jetpack

Ken Baldauf

Senior Software Engineer @ Acorns

Android Studio

  • New versioning scheme to better align with IntelliJ
    • Code names that increment alphabetically
    • Arctic Fox 2020.3.1 in beta
    • Bumblebee 2021.1.1 in canary
  • Arctic Fox has 3 main focusses:
    • Design
    • Devices
    • Developer Productivity

Design

  • Compose Preview
    • Visualize Compose UI components
    • Preview components across different configurations
    • Ability to deploy preview directly to a device
  • Layout Inspector now supports Compose
  • Live edit literals when using Compose
  • Accessibility Scanner
    • Integrates with Android Accessibility Test Framework
    • Tool within the Layout Editor to report accessibility issues and suggest fixes

Devices

  • New Wear OS pairing assistant
    • Easier to pair Wears OS emulator with physical or virtual devices
  • Improvements to Wear OS emulators
    • Emulators can now emulated heart rate sensor
  • New emulator support for:
    • Google TV
    • Foldables 

Developer Productivity

  • New lint checks for Android 12
  • Refactor tool for migrating to non-transitive R
    • R classes don't contain resources from dependencies
    • Makes it explicit where resources are coming from
    • Improves build performance for modular projects
  • Background Task Inspector
    • Visualize, monitor & debug background workers
    • API 26+ & WorkManager 2.5.0+
  • Improvements to memory profiler
  • Test Matrix
    • Displays test results ran across multiple devices in parallel

Unified Test Platform

  • New test executor
  • Previously known as Nitrogen
  • Modular plugins add functionality to test execution
  • Allows for shorter release cycle
  • Leading to the development of Gradle Managed Device
  • Android Studio uses Android Gradle Plugin test runner
    • Previously used IntelliJ test runner
    • Ensures test ran in Android Studio behave the same as they do on CI servers
    • Arctic Fox moves unit tests to AGP test runner
    • Bumblebee moves instrumented tests

Gradle Managed Device

  • Experimental feature
  • Define virtual devices via Gradle DSL
    • Device groups run across multiple devices in parallel
  • Android Gradle Plugin responsible for managing devices
    • Downloads system images & sdks
    • Caches test results and emulator snapshots
    • Guarantees clean state between test runs
  • Android Test Retention
    • Automatic snapshot upon test failures
  • Restore emulator to state when failure was encountered
  • Can import test-result.pb file from a non-AS test run into AS for inspection of the test results

Gradle Managed Device

testOptions {
  devices {
    pixel2api29 (com.android.build.api.dsl.ManagedVirtualDevice) {
      device = "Pixel 2"
      apiLevel = 29
      systemImageSource = "google"
      abi = "x86"
    }
    nexus9api30 (com.android.build.api.dsl.ManagedVirtualDevice) {
      device = "Nexus 9"
      apiLevel = 30
      systemImageSource = "google"
      abi = "x86"
    }
  }
  deviceGroups {
    phoneAndTablet {
      targetDevices.addAll(devices.pixel2api29, devices.nexus9api30)
    }
  }
}

// ./gradlew -Pandroid.experimental.androidTest.useUnifiedTestPlatform=true 
//.    phoneAndTabletGroupDebugAndroidTest

// ./gradlew -Pandroid.experimental.androidTest.useUnifiedTestPlatform=true 
//     pixel2api29DebugAndroidTest

Android Gradle Plugin

  • Decoupled Android Studio & AGP versions
  • Configuration Caching 
    • Serializes task tree for reuse between runs
    • Gradle is more agressive about running parallel tasks
  • Improved lint performance
    • Won't rerun for unchanged libraries
    • Working towards making it cacheable in the future
  • Improved AGP update assistant in Android Studio
    • Shows preview of changes before you make them
  • New Variant API for building gradle plugins

Kotlin Symbol Processing

  • New solution for annotation processing in Kotlin
  • Currently in Alpha; compatible with Kotlin 1.4.30+
  • 2x faster than Kotlin Annotation Processing Tool (KAPT)
    • KAPT creates Java stubs that run through Java's annotation processor
    • KSP offers API for parsing Kotlin code directly
    • KSP is built with multiplatform compatibility in mind
  • Room already offers experimental support for KSP
  • Dagger and other important annotation processors will convert once KSP is stable

Jetpack Versioning

  • Jetpack libraries will now reach Beta faster
    • Previously libs stayed in alpha a long time
    • APIs will only change in response to critical issues or community feedback
    • Feature stabilization will be driven by feature isolation
  • Feature isolation
    • Used to mark some features as experimental
    • Experimental features will necessitate an explicit opt in annotation where utilized
    • Experimental annotation and lint check are used heavily in Jetpack
      • Also available for anyone to use in apps & libraries

Jetpack Stable

  • CameraX & Hilt reached 1.0.0
  • Paging 3.0
    • Complete Kotlin rewrite
    • First class support for coroutines and Flow
  • Security Crypto
    • Safely, easily encrypt files and shared preferences
    • DataStore integration coming soon
  • Fragment
    • Cleaned up internal implementation
    • Reduced undocumented behavior
    • New FragmentOnAttachListener interface to replace the onAttachFragment method

Jetpack Beta

  • Compose
    • Planned to go stable in July
  • ConstraintLayout 2.1
    • Carousel - a motion helper to build carousel views
    • Improved support for foldable devices
  • DataStore
    • Storage solution; alternative to SharedPreferences
    • Fully async with Rx & coroutines + Flow support
    • Multiple backing implementations:
      • Proto DataStore - strongly typed
      • Preference DataStore - key -> value pairs
      • Plug in your own (ex: Kotlin Serialization)

DataStore

Jetpack Alpha

  • Emoji2
    • New version of EmojiCompat with smaller footprint
    • Included by default in AppCompat 1.4+
  • Macrobenchmark
    • Added to existing Jetpack benchmark library
    • Measure app start-up and scrolling performance
  • Navigation - support for multiple backstacks
  • Google Shortcuts
    • Dynamic shortcuts for Google Assistant
  • Window Manager - support new device form factors
    • Initial release aimed at foldable devices
    • Will extend to more display types & window features

AppSearch

  • Jetpack Alpha
  • High performance full-text search functionality
  • Supports
    • Multiple languages
    • Fuzzy matching
    • Synonyms & spelling correction
  • 1.0.0-alpha01 works with LocalStorage
  • In the future, Android S and later will allow devs to surface their data in device wide search

Room & WorkManager

  • Room
    • Stable - 2.3
      • Experimental support of Kotlin Symbol Processing
      • Support for Enums and RxJava3
    • Alpha - 2.4
      • Adds support for auto-migrations
  • WorkManager
    • Stable - 2.5
      • Support for multiprocess apps
    • Alpha - 2.7
      • Support for new Android S foreground restrictions

Google I/O 2021 Recap

By Kenneth Baldauf

Google I/O 2021 Recap

A recap of the latest updates in developer tools & Jetpack from Google I/O 2021

  • 266