Android Studio Dolphin Extends Jetpack Compose, Wear OS, and Test Automation Integration
MMS • Sergio De Simone
Article originally posted on InfoQ. Visit InfoQ
The latest release of Android Studio, dubbed Dolphin, improves Jetpack Compose screen previews, 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 aim to reduce boilerplate code through preview 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 copy-pasting the definitions themselves, as developers had to do until now. The following snippet shows how you can define a FontScalePreviews
annotation and use it in a preview composable:
@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 helps previewing and fine-tuning animations by allowing you to freeze an animation or run it frame-by-frame.
The Compose recomposition count, available in the Layout Inspector, shows how often a view is recomposed, that is re-rendered. This can help identify cases where too frequent recomposition may negatively impact performance.
Gradle Managed Virtual Devices is a new feature that aims to make it easier to manage and setup emulators using for testing. Instead of having to manually execute all required steps to provision an emulator for testing, you can now describe which virtual devices you want in your build.gradle
file. The tool will then download the corresponding SDK, if necessary, provision and set up the emulator, and run your tests. This is how you can 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 is also enhanced in Android Studio Dolphin. This includes a new Wear OS Emulator Pairing Assistant which helps managing and pairing multiple Wear OS devices; improved emulation toolbar which better aligns to physical devices and makes it possible to emulate palm gestures and tilting; and, better support for launching a Wear OS app into the exact state you expect it to be directly from the IDE.
As a final note, Android Studio Dolphin updates its compiler toolchain to IntelliJ 2021.3, which includes a number of improvements including better Kotlin debugging, improved suggestions, and remote coding support.
Android Studio Dolphin can be downloaded from Google Android website or installed directly from a previous version.