Skip to main content

Notes - Android Jetpack: What’s New in Android Support Library (Google I/O 2018)

note

This article has been translated by Gemini.

In this Notes article, I roughly jotted down notes in English from the content of the English session video/podcast. This article is intended to be read as a reference while watching the video. I hope this article helps you even a little when you watch the actual video. (Please feel free to contact me if there are any errors or typos! m(__)m)

This article is based on Android Jetpack: What’s New in Android Support Library (Google I/O 2018).

f🆔shaunkawano:20180514095248p:plain

Packaging
#

Current Package Name
#

  • com.android.support
    • support-v4
    • support-v13
    • appcompat-v7
    • cardview-v7
    • gridlayout-v7
    • mediarouter-v7
    • palette-v7
    • preference-v7
    • preference-v14
    • recyclerview-v7

Packaging, Versioning, Releasing
#

  • Forming the foundation for Jetpack: Android Extension Libraries = AndroidX

Jetpack
#

  • Guidance
  • Recommended libraries and tools
  • Has a cute logo

AndroidX
#

  • The libraries themselves
  • Technical guarantees
  • Does not have a cute logo

Finer-grained Artifacts
#

  • Feature-based Maven groupId and artifactId
  • Scoped to individual widgets and use cases
  • Compatible with old artifacts
  • Binary compatible

Refined Versioning
#

  • Reset from 28.0.0 to 1.0.0
  • Strict semantic versioning:
    • Major - binary compatibility
    • Minor - feature release
    • Bug fix
  • Per-artifact versioning & release
  • Dependencies defined in POM

Updated Packaging
#

  • Refactored to androidx Java packages: androidx.<feature>.ClassName
  • Consistent Maven naming schemes: androidx.<feature>:<feature>-<sub-feature>
  • Removed -v7, -v4, etc., naming

Examples
#

Support Library 28.0.0-alpha1 => AndroidX 1.0.0-alpha1
#
com.android.support:multidex
=> androidx.multidex:multidex

com.android.databinding:adapters
=> androidx.databinding:databinding-adapters

android.arch.persistence.room:common
=> androidx.room:room-common

com.android.support:support-compat
=> androidx.core:core

com.android.support:cardview-v7
=> androidx.cardview:cardview

Migrating to AndroidX
#

  • Tooling for automatic source migration
    • Available in Android Studio 3.2 Canary 14+
    • Wait until Canary 15 to start using this
  • Jetifier tool for prebuilt JAR, AAR transformation
    • Available as a standalone JAR or Gradle plugin
  • Use Automated Refactoring (As of 05/12/18: Available in Android Studio 3.2 Canary 14)
    • “Refactor to AndroidX…”
  • Support Library 28.0.x
    • Parity with AndroidX 1.0.x libraries
    • Same old android.support Java package
    • Same old com.android.support Maven groupId
  • No feature releases after 28.0.0

New Features
#

RecyclerView Selection
#

  • Touch and mouse-driven
  • Preserves state between Activity lifecycle events
  • Fine-grained control
dependencies {
  implementation "androidx.recyclerview:recyclerview-selection:1.0.0-alpha1"
}
  • Band selection
  • Item selection area
  • Item rejection
  • State management
  • Much more

RecyclerView ListAdapter
#

  • Operates on immutable lists
  • Simplified way to use DiffUtil
  • Provides animated updates
  • Concurrency support
  • Efficiently animates changes
  • See also AsyncListDiffer

androidx.webkit
#

  • Provides access to latest WebView platform APIs (android.webkit.*)
  • Relies on updatable WebView APK
    • API 21+ devices only
dependencies {
  implementation "androidx.webkit:webkit:1.0.0-alpha1"
}

Browser Library
#

  • android.support.customtabs -> androidx.browser
  • Custom tabs supported by major browsers:
    • Chrome
    • Firefox
    • Samsung Internet
  • Browser actions:
    • Allows apps to hook into browser context-click menu
    • Requires browser support: Chrome v66+

HeifWriter
#

  • Writing to HEIF files from:
    • YUV byte buffers
    • android.view.Surface
    • android.graphics.Bitmap
  • API 28+ (backport coming)

Slices
#

Android’s new approach for remote content

  • Templated
  • Interactive
  • Updatable
  • Backwards-compatible through API 19+ (95% of devices)

Goal
#

  • One reusable API for presenting remote app content in Android
  • Templated and Interactive

Launching in Search#

Enhance Suggestions with rich, live app content:

  • App names
  • General terms Reach hundreds of millions of users with Slices backwards-compatibility.
dependencies {
  implementation "androidx.slice:slice-builders:1.0.0-alpha1"
  implementation "androidx.slice:slice-view:1.0.0-alpha1"
  implementation "androidx.slice:slice-core:1.0.0-alpha1"
}

Slice Types
#

  • Shortcut slice
  • Small slice
  • Large slice

Material Components
#

  • Adding more customization for color, type, and shape
  • New components
  • Animations
  • Express your brand
dependencies {
  implementation "com.google.android.material:material:1.0.0-alpha1"
}

Impressions / Summary / Key Takeaways
#

  • Automatic Source Migration is from Canary 15.
  • “Jetifier” is a cool name… watch the linked video to see how it works.
  • “What’s New in Android Support Library” becomes “What’s New in AndroidX” next year!
  • Since I started Android development, I’ve found the packaging of support libraries confusing. Having everything unified under androidx sounds fantastic!

That’s all!