of Support Library • The last version of Support Library is 28.0.0 (released September 21, 2018) • There won’t be Support Library version that is related to API 29! (Android 10) https://youtu.be/Hyt7LR5mXLc
AndroidX • All of Support Library artifacts migrated to the androidx.* namespace… • ...with one exception: Design Support Library com.android.support:design -> com.google.android.material:material • Not a part of Jetpack, hosted and maintained separately https://github.com/material-components/material-components-android
versioning • major.minor.micro-suffix • alpha, beta, rc releases • Separated from Android API version (contrary to Support Library) ◦ versioning (re)started with 1.0.0 • No more minApi suffixes (e.g. appcompat-v7 -> appcompat)
version bumps can require some additional changes to your project or include API/behavior changes • Examine release notes before bumping AndroidX packages versions • Remember about transitive dependencies
70 Jetpack packages • Only stable releases are suitable for production… • ...but it’s worth to check what’s coming up (from time to time) • Early feedback matters ◦ Catch bugs before AndroidX package goes out to production ◦ Suggest API and behavior changes • How to track frequent releases of multiple packages?
since core 1.2.0-alpha01, currently in rc • Notification Bubbles ◦ since core 1.2.0-alpha01, currently in rc • Dark Mode improvements ◦ recreating Activities and various fixes since appcompat 1.1.0 ◦ various fixes in core 1.2.0-alpha01 ◦ dark theme support in browser 1.2.0-alpha07 • Dark Mode (Material Components): ◦ 1.1.0-beta01 contains Material Dark Theme for all components
since stable fragment 1.1.0 (FragmentActivity, Fragment) ◦ since stable appcompat 1.1.0 (AppCompatActivity) ◦ profit: no need to override onCreateView (in most cases) • FragmentFactory ◦ since stable fragment 1.1.0 ◦ manage the creation of fragment instances, removing the strict requirement to have a no-argument constructor ◦ example: dependency injection
1.0.0) • SavedStateRegistry (available in stable savedstate 1.0.0) • The shift is to reduce Activity/Fragment’s responsibility • Remove functionalities from Activity/Fragment, provide them via external classes ◦ The pattern is to obtain the object from Activity/Fragment and use its API ◦ The Activity/Fragment is now composed of the several functionalities • Profits: ◦ Activity/Fragment less complex (also Android’s code less complex) ◦ higher flexibility in your code ◦ less method overrides ◦ more control over code structure
class MyFragment : Fragment, OnBackPressedConsumer { override fun onBackPressed() { // Do something } } class MyActivity : FragmentActivity() { override fun onBackPressed() { // Use FragmentManager to find fragment that overrides OnBackPressedConsumer // Dispatch the flow to the Fragment or call super method if not found } }
fun onAttach(context: Context) { super.onAttach(context) if (context is OnBackPressedDispatcher) { context.addCallback { // Do something } } } } • Remember to unregister the callback!
• Until October, you needed to download AOSP repository and build a special version of Android Studio • Now androidx.ui packages available on Google’s maven • No release notes yet • Current version: 0.1.0-dev03 implementation("androidx.ui:ui-core:0.1.0-dev03") implementation("androidx.ui:ui-layout:0.1.0-dev03") implementation("androidx.ui:ui-framework:0.1.0-dev03") implementation("androidx.ui:ui-material:0.1.0-dev03") implementation("androidx.ui:ui-foundation:0.1.0-dev03") implementation("androidx.ui:ui-text:0.1.0-dev03")
currently in rc) ◦ coroutines in Lifecycle and LiveData (2.2.0, currently in rc) • Navigation ◦ scoping ViewModels to a navigation graph - sharing the data between destinations in the same graph (2.1.0 stable) • Room ◦ incremental annotation processor (2.2.0 stable) ◦ @Query methods returning Flow (2.2.0 stable)
the appropriate AndroidX library instead of a Support Library. android.enableJetifier=true The Android plugin automatically migrates existing third-party libraries to use AndroidX by rewriting their binaries.
their transitive dependencies, even if they don’t need to be migrated • Takes 12 seconds on my medium-sized project (see https://proandroiddev.com/the-state-of-jetification-in-early-2019-plus-a-bonus- gradle-plugin-aac5854af910) • Can be a problem when running clean builds (e.g. on CI) • Most of the libraries already migrated to AndroidX: ◦ Firebase, Dagger, Glide, ButterKnife, Epoxy, LeakCanary (2.0) • Some of the libraries didn’t migrate yet: ◦ Facebook SDK • How do I know if can I drop Jetifier?
each of the modules) whether there are any dependencies using support library instead of AndroidX artifacts. ./gradlew -Pandroid.enableJetifier=false canIDropJetifier Cannot drop Jetifier due to following external dependencies: * com.facebook.android:facebook-android-sdk:5.8.0 \-- com.facebook.android:facebook-login:5.8.0 \-- com.android.support:appcompat-v7:27.0.2 or No dependencies on old artifacts! Safe to drop Jetifier.
now’s the time • Be aware of Jetpack’s new versioning and implications • Check out (from time to time) alpha, beta, rc versions and the release notes • Jetpack is not only a support layer for newer AOSP features… • ...but also provides many useful features... • ...not only bigger, but also smaller ones - still very useful! • Be aware of the Jetifier tool and drop it when you can ◦ If you use my plugin I will be happy :-)