Android Studio Dolphin Expands Integration of Jetpack Compose, Wear OS and Test Automation


The latest version of Android Studio, called Dolphin, improves Jetpack Compose’s screenshots, extends Wear OS support, and introduces Gradle Managed Virtual Devices to simplify test automation.

Jetpack Compose Screen Preview gets three new features: multipreview annotations, an animation inspector, and recomposition counts. Multipreview annotations are intended to reduce boilerplate code by providing sample definitions that specify which devices to generate previews for, the fonts and themes to use, and so on. Annotations can then be reused to avoid copying and pasting the definitions themselves, as developers had to do until now. The following excerpt shows how to use a . can define FontScalePreviews annotate and use it in a buildable preview:


@Preview(
    name = "small font",
    group = "font scales",
    fontScale = 0.5f
)
@Preview(
    name = "large font",
    group = "font scales",
    fontScale = 1.5f
)
annotation class FontScalePreviews

...

@FontScalePreviews
@Composable
fun HelloWorldPreview() {
    Text("Hello World")
}

The Animation Preview Inspector aids in viewing and fine-tuning animations by allowing you to freeze an animation or run it frame by frame.

The number of recompositions, available in the Layout Inspector, shows how often a view is recomposed, that is, redisplayed. This can help identify instances where reassembling too often can negatively impact performance.

Gradle Managed Virtual Devices is a new feature that aims to make it easier to manage and set up emulators used for testing. Instead of manually performing all the required steps to provision an emulator for testing, you can now describe which virtual devices you have in your build.gradle File. The tool will then download the corresponding SDK if necessary, set up and set up the emulator, and run your tests. This is how to use this feature inside gradle.build:


android {
    managedDevices {
        devices {
            pixel2api30 (com.android.build.api.dsl.ManagedVirtualDevice) {
                device = "Pixel 2"
                apiLevel = 30
                systemImageSource = "google-atd"
            }
            ...
        }
    }
}

As mentioned, Wear OS support has also been improved in Android Studio Dolphin. This includes a new Wear OS Emulator Pairing Assistant that helps manage and pair multiple Wear OS devices; improved emulation toolbar that is better suited to physical devices and allows to emulate palm movements and tilt; and better support for launching a Wear OS app in the exact state you expect, right from the IDE.

As a final note, Android Studio Dolphin is updating its compiler toolchain to IntelliJ 2021.3, which includes a number of improvements, including better Kotlin debugging, improved suggestions, and support for remote coding.

Android Studio Dolphin can be downloaded from the Google Android website or installed directly from an earlier version.