Skip to content

Android Studio 4.0: The best Android Studio release yet?

During these uncertain times, Android Developers are busier than ever as work from home becomes the new normal. This means build power and productivity are more important now than they ever were.

So on May 28th, Google released a new major version of their trademark mobile platform development IDE, Android Studio 4.0. With it comes a host of amazing features that address animation, building layouts, smart editor features, Java 8 backwards compatibility, cpu profiling and build analysing.

Any one of these features could have been enough to make any Android Developer’s day, but getting all this in one STABLE package is just an absolute treat.

Let’s go over some of the key features that Android Studio 4.0 brought to the table.

Disclaimer: the images in this post are taken from the official docs and youtube channel.

The new features of Android Studio 4.0 can be grouped into 3 categories: design, build, and develop.




Motion Editor

Easily the most mind-blowing of the new features. Motion Layout has been a powerful trend since its release due to its ability to create complex animations, but there was a corresponding amount of complexity and effort in making the XML files for these animations.

It provides an interface for creating, editing, and previewing Motion Layout animations by using constraint sets, transitions, keyframes, and view attributes, in an almost standard video-editor style. The Motion Editor generates these XML files for you, and you don’t have to build or run your app to preview the animations you made.

The XML design drag-and-drop builder is something most developers choose not to utilise because of the inconsistencies it can produce, but the Motion Editor is one feature I see developers not only using, but gracefully abusing to its fullest.

Layout Inspector Hierarchy, 3D Representation, and Layout Validation

You heard it right fellas. You can now see your layout in 3D. You might ask, what’s this for? Seeing the elevation on my views? Perhaps, but not just. This allows you to more easily view your view hierarchy as you’ll be able to see your layouts and the views on top of them in a new fashion which lets you see each individual piece all too clearly.

And if that wasn’t enough, you can now also see the hierarchy of your views just to make getting that cleat image of your layout that much easier. This will help shorten debug times for UI-related bugs. If you’re deploying to a device running API 29 or higher, you can also see a more dynamic representation of your layout hierarchy that updates as views change.

And if THAT wasn’t enough, 4.0 brings the new Layout Validation feature that lets you see how your UI looks on different screen-sizes and resolutions based on either real Pixel devices or your own custom settings to help you verify that your UI looks how it should across the board. On top of this as well is the ability to preview how your app looks with different font sizes and colour blindness settings to help your app all the more accessible.

The Layout Inspector can be accessed via View > Tools Windows > Layout Inspector.

If we had a release containing this and nothing else, I would’ve been happy, but it doesn’t end here. Oh nowhere near.



Build Analyser

Android Studio 4.0, or particularly the Android Gradle Plugin 4.0.0 did a lot to help improve build speeds for our projects.

Most notable is the Build Analyzer. To set up our project for the requirements it needs, developers often have to include Gradle plugins and use custom build logic, but what often leads to longer build times are when when these plugins are outdated or those tasks are misconfigured.

Build Analyzer identifies those cases and gives you actionable feedback on how to address these bottlenecks in your build times.

Enabling and Disabling Build Features

android {
    // The default value for each feature is shown below. You can change the value to
    // override the default behavior.
    buildFeatures {
        // Determines whether to generate a BuildConfig class.
        buildConfig = true
        // Determines whether to support View Binding.
        // Note that the viewBinding.enabled property is now deprecated.
        viewBinding = false
        // Determines whether to support Data Binding.
        // Note that the dataBinding.enabled property is now deprecated.
        dataBinding = false
        // Determines whether to generate binder classes for your AIDL files.
        aidl = true
        // Determines whether to support RenderScript.
        renderScript = true
        // Determines whether to support injecting custom variables into the module’s R class.
        resValues = true
        // Determines whether to support shader AOT compilation.
        shaders = true

The Android Gradle Plugin 4.0.0 also lets you have more control over build features which lets you optimise build performance by disabling the build features your app doesn’t need.

Dependencies Metadata

When building your app with Android Gradle Plugin 4.0.0, metadata that describe your app’s dependencies are included when it’s compiled. When your app is uploaded to the Play Console, the console runs a check on those dependencies and alerts you if it detects any dependencies with known issues and provides you actionable feedback.

This metadata is compressed, encrypted by a Google Play signing key, and stored in the signing block of your release app. This will be enabled by default but you can choose to opt-out by adding this to your module’s build.gradle file.

android {
    dependenciesInfo {
        // Disables dependency metadata when building APKs.
        includeInApk = false
        // Disables dependency metadata when building Android App Bundles.
        includeInBundle = false

Java 8 Language library desugaring in D8 and R8

Previous Android Gradle Plugin versions supported some Java 8 features such as lambdas and method references through a process called desugaring.

According to Collin’s dictionary, the definition of desugaring is:

to rewrite (computer code) in a more refined and concise form; to remove all unnecessary syntactical elements from (computer code)

For other Java 8 features however, such as, java.util.function and java.time, you could only support these in recent Android release versions. But now using the Android Gradle Plugin 4.0.0, the desugaring engine has been extended to support even more of these APIs for all Android API levels.

Below is a list of the new Java 8 APIs supported via desugaring:

  • Sequential streams (
  • A subset of java.time
  • java.util.function
  • Recent additions to java.util.{Map,Collection,Comparator}
  • Optionals (java.util.Optional, java.util.OptionalInt and java.util.OptionalDouble) and some other new classes useful with the above APIs
  • Some additions to java.util.concurrent.atomic (new methods on AtomicInteger, AtomicLong and AtomicReference)
  • ConcurrentHashMap (with bug fixes for Android 5.0)

Feature-on-feature dependencies

If you’re using Dynamic Modules, you’ll know that each module can only depend on the app’s base module. With Android Gradle Plugin 4.0.0, modules can now depend on other dynamic modules. This lets you further optimise your modules.

When your app requests to download a dynamic module, it will also download its parent modules. Where this helps is when the parent module is requested for download, it doesn’t need to download its child modules. Previously if you had wanted to write a module that depended on another one, you had no choice but to bundle them as a single module but this lets you keep things more… modular.

Kotlin DSL Support

Android Studio 4.0 now has built-in support for Kotlin build script files (*.kts) which means that certain Android Studio features such as the Project Structure dialog and build script quick fixes now also support reading and writing to Kotlin build script files.


Improved CPU Profiler

Android Studio 4.0 brings a new CPU Profiler fresh with these improvements:

  • CPU recordings are now separated from the main profiler timeline and organised in groups to allow for easier analysis.
  • You can now view all thread activity in the thread activity timeline including methods, functions, and events.
  • Events are now uniquely coloured to make them easier to differentiate.

Smart Editor when writing rules for code shrinking

In Android Studio 3.4.0, R8 was introduced which allowed you to combine desugaring, shrinking, obfuscating, optimising, and dexing all in one step. When creating rules files for R8, Android Studio now provides smart editor features, such as syntax highlighting, completion, and error checking.

The editor also integrates with your Android project to provide full symbol completion for all classes, methods, and fields, and includes quick navigation and refactoring.

Kotlin Android Live Templates

Live Templates weren’t impossible for Kotlin before Android Studio 4.0, but you had to configure them all for yourself. With the new release, Android Studio now provides standard Android-specific live templates by default, such as one for Toast.

Live Templates can be found and configured in Settings (or Preferences) > Editor > Live Templates.

IntelliJ IDEA 2019.3 Platform Update

Android Studio 4.0 benefits from the latest improvements of IntelliJ IDEA which mainly focus on quality and performance improvements across the IDE.

Clangd support for C++

For C++, Android Studio 4.0 switches over to Clangd as the primary language analysis engine for code navigation, completion, inspection, and showing code errors and warnings. Android Studio 4.0 also comes bundled with clang-tidy.

You can configure clangd or clang-tidy via Settings (or Preferences) > Languages & Frameworks > C/C++ > Clangd / Clang-Tidy.

Get Android Studio 4.0

Download Android Studio 4.0 from the official download page. You can also try out the canary release of Android Studio 4.1 from the preview release download page which includes updates themes and styles in new project templates, preventing new and existing databases from closing, and other general fixes.

That’s the gist of the new features of Android Studio 4.0. Truly a gift bestowed upon us by the Google gods, and arguably the best release we’ve gotten up to this point. Be sure to check the full release notes and as always, happy coding ༼ つ ◕_◕ ༽つ.


Published inAndroid