Nov 23, 2020, Mobile

New is always Better! Changes in Android Studio 4.1

Krzysztof Anczura Android Developer

Today’s article covers some of the changes made for the Android Studio IDE and their brief description. The stable version was released on October 12 2020 and the table of introduced changes is presented below.

Android Studio 4.1 – Design 

Material Design Components updates

Android Studio templates in the Create New Project dialog now use Material Design Components (MDC) and follow the updated themes and styles guidelines by default. These changes will make it easier to use the recommended material styling patterns and will support modern UI features. They will be especially useful in projects that use a dark theme, making it easier to separate the default theme from the dark one.

Updates include:

  • MDC: Projects depend on in build.gradle. Base app themes use Theme.MaterialComponents.* parents and override updated MDC color and “on” attributes.
  • Color resources: Color resources in colors.xml use literal names (for example, purple_500 instead of colorPrimary).
  • Theme resources: Theme resources are in themes.xml (instead of styles.xml) and use Theme.<ApplicationName> names.
  • Dark theme: Base application themes use DayNight parents and are split between res/values and res/values-night.
  • Theme attributes: Color resources are referenced as theme attributes (for example, ?attr/colorPrimary) in layouts and styles to avoid hard-coded colors.

Android Studio 4.1 – Develop

Database Inspector

Every developer needs a tool to debug SQLite or Room database. Good for us, Android Studio 4.1 gives new tools that will make it way easier. Database Inspector will allow inspection, query and modification of databases in your app.

Executing Queries in Database Inspector

The best thing about the database inspector is the possibility to see the data in the local database on inspector by executing queries. There are two possibilities to do so. First by Dao queries and second by Custom Queries.

Dao queries

We can actually run Dao functions using the database inspector and see the data. This feature comes in handy while you’re debugging. After invoking Database Inspector you’ll see a Run symbol beside each function in Dao classes. Click on this symbol will execute the queries in Database inspector 

Custom queries

Second possibility lets us run custom SQL queries against your app’s databases while your app is running. Results from the query are displayed in the new query tab. They can be read only and cannot be modified. To work on, you can use custom SQL query fields such as UPDATE, INSERT or DELETE. If your app uses Room and your UI observes the database, then any changes you make to the data are visible in your running app immediately. Otherwise, changes will be visible after restarting an application and after reading modified data from the database.

Update Data

If you can’t update the data from the inspector, all the features above won’t be much of a use. So, the Android Studio team also included a way to alter or add data to the database from the inspector itself. You can see the changes in the device in a matter of seconds if you’re using Room and observing data through livedata/flow.

To update the data, you just need to double-click on the field and add/remove the data. After that, press Enter to update it in the database. Have a look:

Live Updates

Another great feature is that if there are any changes to the database, we can see them instantly in the inspector. All we need to do is to click the checkbox “Live updates” in the database inspector. When it’s checked, the database inspector automatically displays changes the app makes in its database.

Run Android emulator directly in Android Studio

Right now the Android emulator can be run directly in Android Studio. Expanding this feature will save space on the screen, allow us to quickly navigate between the emulator and the editor window using hotkeys, and improve the organization of the IDE and emulator workflow in one application window.

Dagger Navigation Support

Dagger users will also get a small convenience. To simplify navigation between dagger-related items. Providing new gutter actions and extending support in the Find Usages window.

  • New gutter actions: For projects that use Dagger, the IDE provides gutter actions that help you navigate between your Dagger-annotated code.There are two types of action. First one navigates to the provider of the type and is shown in IDE by this icon

Conversely, clicking on the gutter action navigates you to where a type is used as a dependency.

  • Find Usages node: By invoking Find Usages on a provider of a given type, the Find window now includes a Dependency consumer(s). By invoking this action on a consumer of a Dagger-injected dependency, the Find window shows you the provider of that dependency.

TensorFlow Lite models

Created by the Google Brain team, TensorFlow is an open source library for numerical computation and large-scale machine learning. TensorFlow bundles together a slew of machine learning and deep learning (aka neural networking) models and algorithms and makes them useful by way of a common metaphor. It uses Python to provide a convenient frontend API for building applications with the framework, while executing those applications in high-performance C++. First release date was november 9, 2015. 

Right now, if you are going to use machine learning in your app by importing TensorFlow Lite models and using them in your project directly, it will generate a binding class. Android Studio generates classes so you can run your model with less code and better type safety. To get full potential it is necessary to use models which have the new TensorFlow metadata. The current implementation of ML Model Binding supports image classification and style transfer models, provided they are enhanced with metadata.

In order to learn the details of the imported model and receive instructions in the app, double-click the model file .tflite.

Android Studio 4.1 – Build & Test

Android Emulator – Foldable Hinge Support

Recently, the emulator has been extended to support 5g cellular tests. Now, new functionalities are slowly added to the possibility of handling folded phones. And it should not surprise anyone as folded phones have been on the market for a year. So while a year ago we would mainly talk about Samsung thanks to Fold, now we will find folding phones on the market directly from Huawei, Motorola, Lg and more.

Operating on folded screens in the emulator provides us with the help of WindowMenager, which allows us to create consistent environments responding to the state of folded screens

Apply Changes updates

Apply Changes are available in Android Studio since version 3.5. In the discussed version we’ve got some enhancements for devices running Android 11 Developer Preview 3 or higher.

Faster deploy speeds:

After an initial deploy, subsequent deploys to Android 11 devices using either Apply Code Changes or Apply Changes and Restart Activity are now significantly faster.

Support for additional code changes:

Add methods and then deploy those changes to the running app by clicking either Apply Code Changes or Apply Changes and Restart Activity.

Export C/C++ dependencies from AARs

Android Gradle Plugin 4.0 added the ability to import Prefab packages in AAR dependencies. We wanted to extend the capability of this feature to support sharing native libraries as well. AGP version 4.1 enables exporting libraries from your external native build in an AAR for an Android Library project.

Symbolification for native crash reports

When a crash or ANR occurs in native code, the system produces a stack trace. Now, if you are human, you need a little bit of help to get readable function names. For example right now if you use C++ you can upload debug symbols files to the play console for each version of your app. It would be as Files with debug symbols will be used to make it easier to analyze crashes and ANRs. Adding this solution will definitely help the game developer to identify and fix any problems. 

Android Studio 4.1 – Optimize

System Trace UI Improvements

The Trace UI System also got new improvements. Among other things, the selection of interesting paths was made easier, a new analysis tab was added, and the amount of data on frames was increased:

  1. Box selection: In the Threads section, dragging the mouse will select a rectangular box. Selected items can be placed next to each other to analyze several stories simultaneously.
  2. Summary tab: The new Summary tab in the Analysis panel displays:
  • Aggregate statistics for all occurrences of a specific event, such as an occurrence count and min/max duration.
  • Trace event statistics for the selected occurrence.
  • Data about thread state distribution.
  • Longest-running occurrences of the selected trace event.
  1. Display data: In the Display section, new timelines for SurfaceFlinger and VSYNC help you investigate rendering issues in your app’s UI.

Standalone profilers

Standalone Android Studio Profilers right now allows us to profile our application without running the full IDE.

Native Memory Profiler

With Android Studio version 4.1 memory profiler includes a Native Memory Profiler for apps deployed to physical devices running Android 10. Support for Android 11 devices will be available in version 4.2.

The Natvie Memory Profiler will track allocations/deallocations of objects in natvie code and will provides following informations for a specific time period.

  • Allocations: A count of objects allocated via malloc() or the new operator during the selected time period.
  • Deallocations: A count of objects deallocated via free() or the delete operator during the selected time period.
  • Allocations Size: The aggregated size in bytes of all allocations during the selected time period.
  • Deallocations Size: The aggregated size in bytes of all freed memory during the selected time period.
  • Total Count: The value in the Allocations column minus the value in the Deallocations column.
  • Remaining Size: The value in the Allocations Size column minus the value in the Deallocations Size column.


You’ve come to an end of my brief overview of the changes in Android Studio 4.1. I encourage all Android developers to test new possibilities and incorporate them slowly into the habit of use. There will certainly be a few things to improve in the process, but each of these tools is designed to help us do our work better and faster. For the brave ones, Android Studio 4.2 Canary 16 is now available in the Canary and Dev channels.

Source materials: