The new big version of Android Studio is here again. Links: originally developer.android.com/studio/rele…
Android Studio Arctic Fox is a major update that includes a variety of new features and improvements, including: version number rule changes, support for new test modes, more advanced debugging tracking, easier export of databases, support for Compose, and more
The new version number
Updated version numbers for Android Studio
The Android Studio version number rules have been changed to be more consistent with IntelliJ IDEA, the IDE on which Android Studio is based.
In the previous version numbers, the version numbering rule was Android Studio 4.3 or Version 4.3.0.1. With the new version numbering rule, It will Android Studio – Arctic Fox | 2020.3.1 or 2020.3.1 versions.
Here’s how the Android Studio version number will be determined in the future:
<Year of IntelliJ Version>
.<IntelliJ major version>
.<Studio major version>
.<Studio minor/patch version>
- The first two groups of numbers represent the versions of the IntellIj platform on which a particular Android Studio is based, in this case2020.3.
- The third group of numbers represents the major releases of Studio from1To start, each major release is incremented by one.
- The fourth set of numbers represents Studio minor/patch releases from1To start, each minor version is incremented by one.
- There is also A release name for each major release, incrementing from A to Z according to the animal name. This release is called Arctic Fox.
Updated Android Gradle plugin version number
The version number of the Android Gradle plugin (AGP) was changed this time to more closely match the underlying Gradle build tool, so the next version after AGP 4.2 is AGP 7.0.
See Versioning Changes in AGP for more details
Android Gradle plugin 7.0.0
Unit tests now use the Gradle test runner
To improve the overall consistency of test execution, Android Studio now runs all unit tests using Gradle by default, although in general this change does not affect the test workflow in the IDE.
For example, when you click the Run command (visible when you right-click a test class) or its corresponding gutter Action in the context menu, Android Studio will default to running unit tests using the Gradle Run configuration.
However, Android Studio no longer recognizes the existing Android JUnit run configuration, so you need to migrate the Android JUnit run configuration of the project file to the Gradle run configuration.
To create a Gradle test configuration, select the Gradle template following the instructions in creating a New Run/Debug configuration. After creating a new configuration, it will appear in the Edit Configurations dialog box in the Gradle section:
If you want to check Android JUnit configurations that are no longer recognized, you have two options:
- Open manually saved configurations in a text editor. The location of these files is specified by the user, but the files usually appear in
<my-app>/.idea/runConfigurations/
。 - in
<my-app>/.idea/workspace.xml
Temporary configuration and in<component name="RunManager" ... >
Node, for example:
<component name="RunManager" selected="Gradle.PlantTest">
…
<configuration name="PlantTest" type="AndroidJUnit" factoryName="Android JUnit" nameIsGenerated="true">
<module name="Sunflower.app" />
<useClassPathOnly />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="com.google.samples.apps.sunflower.data.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<option name="PACKAGE_NAME" value="com.google.samples.apps.sunflower.data" />
<option name="MAIN_CLASS_NAME" value="com.google.samples.apps.sunflower.data.PlantTest" />
<option name="METHOD_NAME" value="" />
<option name="TEST_OBJECT" value="class" />
<option name="PARAMETERS" value="" />
<option name="WORKING_DIRECTORY" value="$MODULE_DIR$" />
<method v="2">
<option name="Android.Gradle.BeforeRunTask" enabled="true" />
</method>
</configuration>
Copy the code
New background task inspector
You can use the new background Task inspector to visualize, monitor, and debug your application’s background workers.
First deploy the application to a device running WorkManager Library 2.5.0 or later, then select View > Tool Windows > App Inspection from the menu bar.
You can click on the worker to see more details, such as a description of the worker, how it executes, details of its worker chain, and results of execution.
You can also see a visualization of the worker chain by selecting a worker from the table and clicking Show Graph View in the toolbar. You can then select any worker program in the chain to see its details, or you can choose to stop it if it is currently queuing or running.
To return to the table, click Show List View.
To help investigate failed Worker thread issues, developers can stop currently running or queuing Worker threads by selecting from the table and clicking Cancel Selected Worker thread in the toolbar, or by using the All Tags drop down menu. Select workers in the table by tag filtering.
Export data from the database inspector
Developers can now easily export databases, tables, and query results from Database Inspector to save, share, or recreate locally.
When you open an app project in Android Studio and check the project’s apps in the Database Inspector, you can start exporting data in one of the following ways:
- Select a database or table in the Databases panel, and click Export to File near the top of the panel.
- Right-click the database or table in the Databases panel and select Export to File from the context menu.
- When you examine a table or query result in the TAB, click Export to File above the table or query result.
After selecting the Export operation, you can use the Export dialog box to help with the final steps, as shown below. You can choose to Export the data in one or more of the following formats: DB, SQL, or CSV.
Updated UI for recording in Memory Profiler
We integrated the Memory Profiler user interface (UI) for different logging activities, such as capturing heap dumps and logging Java, Kotlin, and native Memory allocations.
The Memory Profiler provides the following options:
- Capture heap dump: Look at the objects in your application that are using memory at a particular point in time.
- Record Native Allocations: Looks at how each C/C++ object is allocated over a period of time.
- Record Java/Kotlin allocations: Looks at how each Java/Kotlin object is allocated over a period of time.
Here’s how to use all three options:
- To Capture a heap dump, select Capture Heap dump, then select Record, and after the analyzer has captured the heap dump, the memory analyzer UI will be converted to a separate page showing the heap dump.
- To use Record Native Allocations on devices running Android 10 and higher, select Record Native Allocations, then Record, and the Record is held until you click Stop, The Memory Profiler UI is then converted to a separate page showing native records.
On Android 9 and earlier, the Record Native Allocations option is not available.
- To Record Java and Kotlin allocations, select Record Java/Kotlin Allocations, then Record. If the device is running Android 8 or later, the Memory Profiler UI is converted to a separate page showing the recording in progress, the developer can interact with the mini-timeline above the discipline (for example, changing the selection range), and can select Stop if the recording is to be completed.
On Android 7.1 and earlier, the memory profiler uses traditional allocation records, which are displayed on the timeline until Stop is clicked.
Update the linked C++ project
The new version has moved configuration unrelated.cxx/ files from the folder to the build/ folder.
CMake C++ builds require a Ninja project that performs the compile and link steps during the configuration phase. Projects generated by CMake are expensive, so hopefully they won’t be cleaned in gradle clean.
Therefore, they are stored in a folder called Build/next to the.cxx/ folder, and usually the Android Gradle plugin will notice the configuration changes and automatically regenerate the Ninja project. But not all cases can be detected, and when this happens, you can manually regenerate the Ninja Project using the “Refresh Linked C++ Project” option.
A new test matrix for multi-device testing
Instrumentation Tests can now run in parallel on multiple devices and can be investigated using a specialized Instrumentation Tests results panel. Use this panel to determine whether the test failed due to API level or hardware properties.
Testing your application at a variety of API levels and form factors is one of the best ways to ensure that all users have a great experience with your application.
To take advantage of this feature:
- 1. Select Multiple Devices from the target Device drop-down menu in the top center of the IDE.
- 2. Select the target device and click OK.
- 3. Run tests.
To View the test results in the Run panel, go to View > Tool Windows > Run.
The new test results panel allows you to filter test results by status, device, and API levels. In addition, you can sort each column by clicking the title, and view the logs and device information for each device individually by clicking a single test.
StateFlow
Data binding support
For Kotlin applications that use coroutines, you can now use the StateFlow object as the data binding source to automatically notify the UI of data changes. The data binding will be lifecycle aware and will only be triggered when the UI is visible on the screen.
To use objects in the StateFlow binding class, you specify the lifecycle owner to define the scope of the StateFlow object, and the ViewModel in the layout uses binding expressions to assign component properties and methods to the corresponding views, as shown in the following example:
class ViewModel(a){
val username: StateFlow<String>
}
Copy the code
<TextView
android:id="@+id/name"
android:text="@{viewmodel.username}" />
Copy the code
If StateFlow is in a Kotlin application using AndroidX, support for data binding is automatically included, including coroutine dependencies.
For more information, see Working with Observable Data Objects.
Improved import of recommendations
Improved the number of libraries supported by the recommended import feature, and updated indexes more frequently.
Recommended imports help developers quickly and easily import certain Google Maven artifacts into classes and Gradle projects. When Android Studio detects unparsed symbols from certain Google libraries, the IDE recommends importing the libraries into the classes and projects.
Support for building configuration caches in parsers
Build Analyzer can now identify when a project is not enabled with configuration caching and provide it as an optimization. Build Analyzer runs a compatibility assessment to notify if there are any problems with the configuration cache in the project before enabling it.
Improved AGP upgrade helper
The Android Gradle plugin’s Upgrade Assistant now has a persistent tools window with a list of steps to complete.
Additional information is also displayed on the right side of the tool window. If you need to upgrade AGP of different versions, click Refresh to update the corresponding update steps.
Refactoring of a nontransitive R class
The intransitive R class can be used in combination with the Android Gradle plug-in for faster builds for applications with multiple modules.
This helps prevent resource duplication and ensures that each module’s R class contains only references to its own resources and does not extract references from its dependencies. This leads to more up-to-date builds and the associated benefit of avoiding compilation.
You can access this function by going to Refactor > Migrate to non-transitive R Classes.
Support for the Jetpack Compose tool
We now provide additional support for previewing and testing applications that use Jetpack Compose.
For the best experience developing with Jetpack Compose, you should use the latest version of Android Studio Arctic Fox so that developers can experience Smart Editor features, Examples include new project templates and the ability to preview the Compose UI immediately.
Compose preview
The following parameters of the @preview method are now available:
- ShowBackground: Turns on and off the preview background.
- BackgroundColor: Sets the color to be used only in the preview surface.
- UiMode: This new parameter can take any configuration.ui_ * constant and allows you to change the behavior of the preview, such as setting it to night mode to see how the theme reacts.
Interactive preview
You can use this feature to interact with your UI components, click on them, and then see how the state changes, which is a quick way to get feedback on UI reactions and preview animations. Enabling it by clicking the Interactive icon preview will toggle modes.
To Stop, click Stop Interactive Preview in the top toolbar.
Deploy to device
You can use this capability to deploy UI fragments to a device, which helps test a small portion of the code in the device without launching the entire application.
Click the Deploy to Device icon next to the @Preview annotation or at the top of the Preview, and Android Studio will Deploy to the connected Device or emulator.
Live Edit of literals
We’ve added a live edit preview of text to help developers using Compose quickly edit text (strings, numbers, Bores) in their code and see the results immediately without waiting for compilation.
The goal of this feature is to help improve developer productivity by showing code changes almost instantly in a preview, emulator, or physical device.
Compose support in the Layout Inspector
The Layout Inspector allows developers to see rich details of the application Layout on connected devices, application interactions, and real-time updates in tools to quickly debug problems that may arise.
Developers can examine layouts written using The new Android declarative UI framework, Jetpack Compose, whether an application uses a layout written entirely by Compose or a hybrid of Compose and Views, The layout inspector can help developers understand how the layout will appear on the running device.
start
First, deploy the application to the connected device, then open the Layout Inspector window by selecting View > Tool Windows > Layout Inspector.
If the Layout Inspector does not automatically connect to the application process, select the desired application process from the process drop down list and you should soon see the application Layout in the tools window.
To begin examining the Compose layout, select it from the Component Tree, the layout Component visible in the render.
The Attributes window displays the details of the currently selected composite functionality. This window allows you to examine the parameters of a function and their values, including modifiers and lambda expressions.
For lambda expressions, the inspector provides a shortcut to help navigate to the expression in the source code.
The Layout Inspector shows all functions of the call stack, components, and the Layout of the application. In many cases, this includes the Compose function called internally by the Compose library. If you just want to see the Compose function in Component Tre called directly by your application, you can click on the filter action, which may help reduce the number of nodes displayed in the tree to the number you might want to check.
Improved deployment dropdown menu
The device drop-down list can now distinguish between different types of errors in the selected device configuration.
Icon and style changes now distinguish between errors (device selections that cause configuration damage) and warnings (device selections that may cause unexpected behavior but still work).
In addition, Android Studio will now issue a warning if you try to launch a project on a device that has an error or related warning.
New Wear OS matching assistant
The new Wear OS Pairing Assistant instructs developers to pair Wear OS emulators directly to physical or virtual phones in Android Studio.
The Assistant helps you install the correct Wear OS Companion app on your phone, and establish connections between your devices. You can do this by going to the Devices drop-down > Wear OS Emulator Pairing Assistant.
Reactive layout templates
Android Studio Arctic Fox now includes a new layout template that can accommodate various display sizes and app resizing, such as phone, foldable device, tablet, and split screen mode.
When creating a new project or module, select a responsive activity template to create a layout with dynamically resized components.
Go to File > New, select New Project or New Module, and then select the Responsive Activity template.
The patch does not apply to Windows for v3.6-V4.1
The v3.6-V4.1 patches to Android Studio Arctic Fox stable for Windows platforms may not work.