Android Rewind: 2020

Anupam Singh
AndroIDIOTS
Published in
9 min readDec 31, 2020

2020 was a tough year for everyone, google I/O 2020 was canceled, iOS supports widgets now (cough cough…)

In wake of covid -19 with the entire world working remotely albeit juggling between work and home we hoped android might also take a break, but no the juggernaut that is Android kept rolling in 2020 as usual.

We don’t want you to get overwhelmed by the amount of stuff Google, Jet-brains shipped together in thousand of articles online, here is a rewind of android as it happened in 2020 (well, the good part only).

Android 11:

New year, New android.

Android 11 in google’s words is

People-centric and expressive, with a new controls space and more privacy features. Extend your apps with conversation notifications and bubbles, try one-time permissions, surface devices and media in the controls. Work faster with tools like compatibility toggles, ADB incremental installs, and more!

With Android 11, Google has taken a step jump in enhancing the privacy of users. As a developer, you need to keep the following points in mind while building apps

  • One Time Permissions: Starting in Android 11, whenever your app requests permission related to location, microphone, or camera, the user-facing permissions dialog contains an option called Only this time. If the user selects this option in the dialog, your app is granted a temporary one-time permission, and if the user denies the permission multiple times it will be considered a ‘Don’t Ask Again’ and the system will not show the permission dialog anymore, the user would have to grant permission from the settings.
  • Permission Auto-Reset : If the user hasn’t interacted with apps for months system will remove sensitive permission access for these apps, to read best practices for request permission read here
  • Scoped Storage: To give users more control over their files and to limit file clutter android introduced scoped storage in android 10 with android 11 its compulsory for all apps to use it.
  • Background Location Access: Now developers have to request background and foreground requests incrementally in separate calls.

To enhance security Android 11 now uses SSL engine of Conscript, and it used Scudo Hardened Allocator internally to service heap allocations. which is capable of detecting and mitigating memory safety violations and now users' app usage stats are stored in credential encrypted storage.

It also comes with a host of new features like chat bubble, support for waterfall screen, Media control settings, and much more find the details here.

And in case confused about how to digest changes in Android 11 Here is a guide by @iamgoddamnbatma on steps to Migrate to Android 11 easily.

Android Jetpack And More :

  • Jetpack Compose: An Android UI toolkit, taking inspiration declarative programming paradigm from the web, android now supports a new way of writing android UI say bye-bye to messy XML files and bloated adapters.
    Read Here to understand the power of composition Compose uses.
  • Dagger Hilt: Finally google has an opinionated way of using dependency injection in android with dagger hilt, hilt simplifies the overall infra for using dagger with standard components and scopes it eases the pain of setup, readability, and testing. Read here to deep dive into Hilt.
  • Data Store: Now you can store key-value pairs and typed objects locally in disk memory, data store is a replacement of Shared Preference Api it also leverages Kotlin Coroutines to store data asynchronously and consistently, so no more headache to synchronize apply and commit.
  • View Pager 2: Built on top of recycler view, the new view pager API has a stable version now, here is a guide to help you migrate from the old view pager.
  • Async Tasks Deprecated in Android 11: Finally some good news to all people who grew up loving to hate this API, some versions had Some versions have parallel execution and some have sequential execution with the special attention needed to not to leak memory limitation of execute() will be only be called from the main thread, the async task had it coming, so now what? well we have kotlin coroutines for the rescue
  • Constraint Layout 2.0: With Flow, a new virtual layout for building chains, Layer, a helper to create virtual layers from several views, and first-class support of motion layout along with motion editor, constraint layout is now even more powerful.
  • State Flow And Shared Flow: Data transfer is the bedrock of software development, and to enhance the existing infra of data communication android now has new APIs in Kotlin Flows. State flow updates the current and new state of data to its collector, and it stays in memory as long as the flow is collected by any collector, Shared flow is a configuration on top of state flow and it emits values to all the collectors that collect from it.
  • Paging 3: With first-class support for Kotlin Coroutines and Flow, built-in error and load state for Responsive UI, and improved repository and presentation layer, paging 3 is now even more powerful than ever, are you already using paging 2 and above features are enticing enough to update have a read here, though paging 3 is currently in alpha so no rush as such.
  • Jetpack App Startup: Every enterprise app has a lot of 3rd party dependencies eg Work Manager, FirebaseApp and these components need to be initialized before Application.onCreate() and content providers to initialize each dependency separately is the way to go about it till now, and obviously, it comes with the cost of time consumed to initialize every dependency independently, App Startup lets you define initializers that share a single content provider. This significantly improves app startup time, usually by ~2ms per content provider.
  • Activity Result Api: Since the Inception of android we have been communicating between two activities bypassing Intent and requestCode through startActivityForResult , we check the request and result code before paring response on onActivityResult , but when the app grows there is a lot of tight coupling in a lot of if cases and becomes very difficult to test, the new Activity Result API which is part of the AndroidX library suite comes with a good abstraction that allows us yo handle onActivityResult() the method in a clean and reusable structure, you can register a callback for an Activity Result, The Activity Result APIs provide components for registering for a result, launching the result, and handling the result once it is dispatched by the system.

Kotlin:

Jetbrains has been very active even during these tough times and shipped new features for Kotlin all year round.

In March, Kotlin 1.3.70 came out with these new changes:

  • @OptIn and @RequiresOptIn have replaced @UseExperimental and @Experimental
  • Double-ended queue implementation: ArrayDeque
  • Collection builders: buildList, buildSet, and buildMap which work similar to buildString
  • Scanning Lists and Sequences: scan() is closely related to fold(). Both scan() and fold() apply the given binary operation to the sequence of values, but differ in that scan() returns the whole sequence of intermediate results, while fold() returns only the final result.

Kotlin 1.4.0 was released in August with a focus on Quality and Performance, with these new updates:

In the most recent release, Kotlin 1.4.21, the major update was the deprecation of kotlin-android-extensions. We’ve all used this library for synthetic views from, and @Parcelize annotation has become our go-to, to avoid writing lots of boilerplate when implementing parcelable’s. Synthetic views are no longer needed since the Android team introduced view-binding (migration guide), so Jetbrains decided to deprecate it, and move @Parcelize to its own kotlin-parcelize package.

Android Studio

Studio 3.6

Studio 4.0

  • Build Analyser: Understand and diagnose issues with your build processes, such as disabled optimizations and improperly configured tasks. The window organizes the possible build issues in a tree on the left and a more detailed description on the right.
  • Java 8 library desugaring in D8 and R8: Android Studio now includes support for using a number of Java 8 language APIs without requiring a minimum API level for your app.
  • Feature-on-feature dependencies: Feature modules can now depend on other feature modules. This means that when your app requests to download a feature module, the app also downloads other feature modules it depends on. You can enable this in-studio from Help > Edit Custom VM Options.
  • Dependencies metadata: When compiling your app with Android Gradle Plugin 4+, a summary of dependencies is stored in build/outputs/sdk-dependencies/release/sdkDependency.txt which PlayStore uses to give alerts and actionable feedbacks on known issues of the SDKs you use.
  • Support for Kotlin DSL script files: The Android Gradle plugin now supports Kotlin DSL build script files (*.kts).
  • CPU Profiler Updates: Error rates are decreased and UI is much more intuitive. CPU recordings are separated from the main timeline for easier analysis and has many more options such as viewing thread activities, flame chart, top-down and bottom-up, etc.
  • New Motion Editor: You can now preview your MotionLayout animations in the design editor. You can move your objects, define states, play the animation in the editor and it’ll automatically generate the corresponding XML code for you!
  • Live Layout Inspector: Debug your layout with an updated Live Layout Inspector that provides complete, real-time insights into your app’s UI while it’s deployed to a device. You can see the dynamic layout hierarchy, resolved properties, a 3D view which is especially helpful with view pagers.
  • Smart editor features for code shrinker rules: With R8 getting stable, the studio got smarter with features like syntax highlighting, code completion, and error checking for rules.

Studio 4.1

  • New Database Inspector: It’s finally here! The long-awaited database inspector lets you inspect, query, and modify your databases in your running app using the new Database Inspector.
  • Run the Android Emulator directly in Android Studio: A lot of devs disliked how they had to switch between emulator and studio all the time, breaking their workflow.
  • Use TensorFlow Lite models: ML Model binding for .tflite models help in generating easy-to-use classes for you to interact with.
  • Native Memory Profiler: If the studio is connected with a device running Android 10 and above, the studio allows you to record memory allocations and deallocations from native code and inspect cumulative statistics about native objects
  • Dagger navigation support: Now you can navigate between your Dagger-related code by providing new gutter actions and extending support in the Find Usages window
  • Material Design Components: Updated themes and styles in new project templates depending on material design and conforming to its guidelines.

Honorable Mention: Firebase

Firebase has shipped some major releases this year, with the most notables ones being :

  • Bye Bye Fabric: Fabric SDK has been officially deprecated since 18th November and crashes will now be reported with firebase’s crashlytics sdk.
  • Firebase Android BoM: The Firebase Android BoM (Bill of Materials) enables you to manage all your Firebase library versions by specifying only one version — the BoM’s version. Super useful as it ensures that all your firebase sdk dependencies are inter-compatible.

We believe this rewind was useful we are also inviting Android Developers across the globe to contribute back to the community via AndroIDIOTS. If you are interested in recording a podcast or writing tech articles, we would love to have you on board. Here is a small form you can fill so we can get back to you.

Happy New Year 2021, Cheers !!

--

--