Android Developers Blog
The latest Android and Google Play news for app and game developers.
🔍
Platform Android Studio Google Play Jetpack Kotlin Docs News

10 toukokuuta 2023

Android Studio @ I/O ‘23: Announcing Studio Bot, an AI-powered coding assistant


Link copied to clipboard
Posted by Adarsh Fernando, Senior Product Manager, Android Studio

We first announced Android Studio at I/O 2013 with a promise to deliver a best-in-class integrated development environment (IDE) focused on Android app developers. 10 years later, this commitment to developer productivity still drives the team to deliver new tools and solutions that help teams around the world to create amazing app experiences for their users. And with Google's push to unlock the power of AI to help you throughout your day, Android Studio Hedgehog introduces a key breakthrough: an AI-powered conversational experience designed to make you more productive.

In addition to accelerating coding productivity, this latest version of the IDE provides better tools when you develop for multiple form factors, and helps you improve app quality with new insights, debugging, and testing solutions. All these improvements add to the many updates we’ve included in Android Studio Giraffe, which is now in the Beta channel and helps make it easier to configure your builds with Kotlin DSL support, improve sync times with new data and guidance, target the latest Android SDK version with the new Android SDK Upgrade Assistant, and more.

To see highlights of the new features in action including Studio Bot, watch the What’s new in Android Developer Tools session from Google I/O 2023.

What’s new in Android Development Tools - with Studio Bot Demo

Jump right in and download Android Studio Hedgehog, or learn more about the most exciting new features below.

Coding productivity

Introducing Android Studio Bot

At the heart of our mission is to accelerate your ability to write high-quality code for Android. In this release we are excited to introduce an AI-powered conversational experience called Studio Bot, that leverages Codey, Google's foundation model for coding that is a descendant of PaLM 2, to help you generate code for your app and make you more productive. You can also ask questions to learn more about Android development or help fix errors in your existing code — all without ever having to leave Android Studio. Studio Bot is in its very early days, and we’re training it to become even better at answering your questions and helping you learn best practices. We encourage you to try it out for yourselves, and help it improve by sharing your feedback directly with Studio Bot.

Privacy is top of mind, and what is unique in this integration is that you don’t need to send your source code to Google to use Studio Bot—only the chat dialogue between you and Studio Bot is shared. Much like our work on other AI projects, we stick to a set of principles that hold us accountable. We’re taking a measured approach to our rollout; for this initial launch, Studio Bot is only available to Android developers in the US. You can read more here

Studio Bot

Live Edit

Live Edit helps keep you in the flow by minimizing interruptions when you make updates to your Compose UI and validates those changes on a running device. You can use it in manual mode to control when the running app should be updated or in automatic mode to update the running app as you make code changes. Live Edit is available in Android Studio Giraffe Beta, with the Hedgehog release providing additional improvements in error handling and reporting.

Moving image showing live edit with Compose
Live Edit with Compose

Build productivity

Kotlin DSL and Version Catalogs

A number of updates help you leverage more modern syntax and conventions when configuring your build. Kotlin is the recommended language when developing for Android. Now, with official support for Kotlin DSL in your Gradle build scripts, it’s also the preferred way to configure your build because Kotlin is more readable and offers better compile-time checking and IDE support. Additionally, we’ve also added experimental support for TOML-based Gradle Version Catalogs, a feature that lets you manage dependencies in one central location and share dependencies across modules or projects. Android Studio now makes it easier to configure version catalogs through editor suggestions and integrations with the Project Structure dialog, plus the New Project Wizard.

Screengrab showing Kotlin DSL and Version Catalogs in the New Project Wizard
Kotlin DSL and Version Catalogs in the New Project Wizard

Per-app language preferences

Typically, multilingual users set their system language to one language—such as English—but they want to select other languages for specific apps, such as Dutch, Chinese, or Hindi. Android 13 introduced support for per-app language preferences, and now Android Gradle plugin 8.1 and higher can configure your app to support it automatically. Learn more.

Download impact during Sync

When using Android Gradle Plugin 7.3 or higher, The Build > Sync tool window now includes a summary of time spent downloading dependencies and a detailed view of downloads per repository, so you can easily determine whether unexpected downloads are impacting build performance. Additionally, it can help you identify inefficiencies in how you configure your repositories. Learn more.

Screengrab of Build Analyzer showing impact of downloads during build
Build Analyzer showing impact of downloads during build

New Android SDK Upgrade Assistant

Android Studio Giraffe introduces the Android SDK Upgrade Assistant, a new tool that helps you upgrade the targetSdkVersion, which is the API level that your app targets. Instead of having to navigate every API change with an Android SDK release, the Android SDK Upgrade Assistant guides you through upgrading targetSdkVersion level by level by creating a customized filter of API changes that are relevant to your app. For each migration step, it highlights the major breaking changes and how to address them, helping you get to taking advantage of what the latest versions of Android have to offer much more quickly. To open the Android SDK Upgrade Assistant, go to Tools > Android SDK Upgrade Assistant. In the Assistant panel, select the API level that you want to upgrade to for guidance.

Screengrab of Build Analyzer showing impact of downloads during build
Upgrade more quickly with the Android SDK Upgrade Assistant

Developing for form factors

Google Pixel Fold and Tablet Virtual Devices

Although these devices won’t launch until later this year, you can start preparing your app to take full advantage of the expanded screen sizes and functionality of these devices by creating virtual devices using new Google Pixel Fold and Google Pixel Tablet device profiles in Android Studio Hedgehog. To start, open Device Manager and select Create Device.

Screengrab of Pixel Tablet running on the Android Emulator
Pixel Tablet running on the Android Emulator

Emulator Support for Wear OS 4 Developer Preview

Wear OS 4 is the next generation OS for Wear. Based on Android 13, it officially launches in the fall and has a great selection of new features and optimizations. We’re giving you a preview of all the new platform features with the new Wear OS 4 emulator. We recommend you try it with Android Studio Hedgehog and test that your Wear OS app works as intended with the latest platform updates. The Wear OS 4 emulator will give you a faster and smoother transition to Wear OS 4, and help you make apps ready in time for the official Wear OS 4 release on real devices. Check out the Wear 4 Preview site for how to get started with the new Wear OS 4 emulator.

Watch Face Format support in Wear OS 4 Emulator

Together with Samsung, we’re excited to announce the launch of the Watch Face Format, a new way to build watch faces for Wear OS. The Watch Face Format is a declarative XML format, meaning there will be no code in your watch face APK. The platform takes care of the logic needed to render the watch face so you no longer have to worry about code optimizations or battery performance. Use watch face creation tools such as Watch Face Studio to design watch faces, or you can manually or dynamically edit the watch face format to build watch faces directly. You can test the new Watch Face Format on the Wear OS 4 emulator.

Moving image of Watch Face Format Watchface on Wear 4 Emulator
Watch Face Format Watchface on Wear 4 Emulator

Device Mirroring for local devices

Whether you use a direct USB connection or ADB over Wi-Fi, Device Mirroring lets you see and interact with your local physical devices directly within the Android Studio Running Devices window. This feature lets you focus on how you develop and test your app all in one place. With the Hedgehog release, we’re adding more functionality, including the ability to mirror Wear OS devices and simulate folding actions on foldable devices directly from the IDE.

Screengrab showing device mirroring with the Pixel Fold
Device Mirroring with the Pixel Fold

Android Device Streaming

We know sometimes it’s critical for you to see and test how your apps work on physical hardware to ensure that your users have the best experience. However, accessing the latest flagship devices isn’t always easy. Building on top of Device Mirroring for local devices, we’re introducing device streaming of remote physical Google Pixel devices, such as the Pixel Fold and Pixel Tablet, directly within Android Studio. Device streaming will let you deploy your app to these remote devices and interact with them, all without having to leave the IDE. If you’re interested in getting early access later this year, enroll now.

Espresso Device API

Automated testing of your app using Espresso APIs helps you catch potential issues early, before they reach users. However, testing your app across configuration changes, such as rotating or folding a device, has always been a challenge. Espresso Device API is now available to help you write tests that perform synchronous configuration changes when testing on Android virtual devices running API level 24 and higher. You can also set up test filters to ensure that tests that require certain device features, such as a folding action, only run on devices that support them. Learn more.

Example of test code for synchronous device configuration changes using the Espresso Device API
Synchronous device configuration changes using the Espresso Device API

Improve your app quality

App Quality Insights with Android vitals

App Quality Insights launched in Android Studio Electric Eel to provide access to Firebase Crashlytics issue reports directly from the IDE. The integration lets you navigate between your stack trace and code with a click, use filters to see only the most important issues, and see report details to help you reproduce issues. In Android Studio Hedgehog, you can now view important crash reports from Android vitals, powered by Google Play. Android vitals reports also include useful insights, such as notes from SDK providers so that you can quickly diagnose and resolve crashes related to SDKs your app might be using.

Screengrab showing Android vitals crash reports in the App Quality Insights window
Android vitals crash reports in the App Quality Insights window

App Quality Insights with improved code navigation

When you publish your app using the latest version of AGP 8.2, crash reports now attach minimal git commit hash data to help Android Studio navigate to your code when investigating Crashlytics crash reports in the IDE. Now, when you view a report that includes the necessary metadata, you can choose to either navigate to the line of code in your current git checkout, or view a diff between the checkout and the version of your codebase that generated the crash. To get started with the right dependencies, see the documentation.

Compose State information in Debugger

When parts of your Compose UI recompose unexpectedly, it can sometimes be difficult to understand why. Now, when setting a breakpoint on a Composable function, the debugger lists the parameters of the composable and their state, so you can more easily identify what changes might have caused the recomposition. For example, when you pause on a composable, the debugger can tell you exactly which parameters have “Changed” or have remained “Unchanged”, so you can more efficiently investigate the cause of the recomposition.

Screengrab showing Compose state information in the debugger
Compose state information in the debugger

New Power Profiler

We are excited to announce a brand new Power Profiler in Android Studio Hedgehog, which shows power consumption on the Pixel 6 and higher devices running Android 10 and higher. Data is segmented by each sub-system (such as, Camera, GPS, and more). This data is made available when recording a System Trace via the Profiler and helps you to visually correlate power consumption of the device to the actions happening in your app. For example, you can A/B test multiple algorithms of your video calling app to optimize power consumed by the camera sensor.

Image of the new power profiler
The new Power Profiler

Device Explorer

The Device File Explorer in Giraffe has been renamed to Device Explorer and updated to include information about debuggable processes running on connected devices. In addition to the Files tab, which includes existing functionality that allows you to explore a device’s file hierarchy, the new Processes tab allows you to view a list of debuggable processes for the connected device. From there you can also select a process and perform a Kill process action (which runs am kill), a Force stop (which runs am force-stop) , or attach the debugger to a selected process.

Image of the processes tab in the Device Explorer window
Processes tab in the Device Explorer window

Compose animation preview

Compose Animation Preview in Android Studio Hedgehog now supports a number of additional Compose APIs, animate*AsState, CrossFade, rememberInfiniteTransition, and AnimatedContent (in addition to updateTransition and AnimatedVisibility). Compose Animation Preview also has new pickers that let you set non-enum or boolean states to debug your Compose animation using precise inputs. For all supported Compose Animation APIs, you can play, pause, scrub, control speed, and coordinate.

Moving image of Compose Animation preview
Compose Animation Preview

Embedded Layout Inspector

You can now run Layout Inspector directly embedded in the Running Device Window in Android Studio! Try out this feature today in Android Studio Hedgehog to conserve screen real estate and organize your UI debugging workflow in a single tool window. You can access common Layout Inspector features such as debugging the layout of your app by showing a view hierarchy and allowing you to inspect the properties of each view. Additionally, because the embedded Layout Inspector overlays on top of the existing device mirroring stream, overall performance when using the inspector is now much faster. To get started and understand known limitations, read the release notes.

Screengrab of embedded Layout Inspector
Embedded Layout Inspector

Firebase Test Lab support for Gradle Managed Devices

Gradle Managed Devices launched in Android Gradle Plugin (AGP) 7.3 to make it easier to utilize virtual devices when running automated tests in your continuous integration (CI) infrastructure by allowing Gradle to manage all aspects of device provisioning. All you need to do is use the AGP DSL to describe the devices you wanted Gradle to use. But sometimes you need to run your tests on physical Android devices. With AGP 8.2, we have expanded Gradle Managed Devices with the ability to target real physical (and virtual) devices running in Firebase Test Lab (FTL). The capability makes it easier than ever to scalably test across the large selection of FTL devices with only a few simple steps. Additionally, this version of AGP can also take advantage of FTL’s new Smart Sharding capabilities, which allows you to get test results back much more quickly by utilizing multiple devices that run in parallel. To learn more and get started, read the release notes.

Image of gradle managed devices with support for Firebase Test Lab
Gradle Managed Devices with support for Firebase Test Lab

IntelliJ

IntelliJ Platform Update

Android Studio Hedgehog (2023.1) includes the IntelliJ 2023.1 platform release, which comes with IDE startup performance improvements, faster import of Maven projects, and a more streamlined commit process. Read the IntelliJ release notes here.

New UI

Along with the IntelliJ platform update comes further improvements to the New UI. In large part due to community feedback, there’s a new Compact Mode, which provides a more consolidated look and feel of the IDE, and an option to vertically split the tool window area and conveniently arrange the windows, just like in the old UI. We also improved the Android-specific UI by updating the main toolbar, tool windows, and new iconography. To use the New UI, enable it in Settings > Appearance & Behavior > New UI. For a full list of changes, see the IntelliJ New UI documentation.

Screengrab showing the new UI adopted from IntelliJ
The New UI adopted from IntelliJ

Summary

To recap, Android Studio Giraffe is available in the Beta channel. Android Studio Hedgehog is the latest version of the IDE and is available in the Canary channel, and includes all of these new enhancements and features:

Coding productivity

  • Android Studio Bot, is a tightly integrated, AI-powered assistant in Android Studio designed to make you more productive.
  • (Beta) Live Edit, which helps keep you in the flow by minimizing interruptions when you make updates to your Compose UI and validate those changes on a running device.

Build productivity

  • (Beta) Kotlin DSL and Version Catalogs, which helps you take advantage of more modern syntax and conventions when configuring your build.
  • (Beta) Per-app language preferences, built-in support in AGP for automatically configuring per-app language preferences.
  • (Beta) Download impact in Build Analyzer, which provides a summary of time spent downloading dependencies and a detailed view of downloads per repository, so you can easily determine whether unexpected downloads are impacting build performance.
  • (Beta) New Android SDK Upgrade Assistant, which helps you upgrade the targetSdkVersion, which is the API level that your app targets, much more quickly.

Developing for form factors

  • Google Pixel Fold and Google Pixel Tablet Virtual Devices, which can help you start preparing your app to take full advantage of the expanded screen sizes and functionality of these devices before they are available in stores.
  • Wear OS 4 Developer Preview Emulator, which similarly provides you early access to test and optimize your app against the next generation of Wear OS by Google.
  • Watch Face Format support in Wear OS 4 Developer Preview Emulator, a new way to build watch faces for Wear OS.
  • Device Mirroring for local devices, which lets you see and interact with your local physical devices directly within Android Studio’s Running Devices window.
  • Android Device Streaming, a device streaming of remote physical Google Pixel devices, which you can register for early access today!
  • Espresso Device API, which helps you write tests that perform synchronous configuration changes when testing on Android virtual devices running API level 24 and higher.

Improve your app quality

  • App Quality Insights: Android vitals, which now lets your view, filter, and navigate important crash reports from Android vitals, powered by Google Play.
  • App Quality Insights with improved code navigation, which lets you now choose to either navigate to the line of code in your current git checkout, or view a diff between the checkout and the version of your codebase that generated the crash.
  • Compose State information in Debugger, which lists the parameters of the composable and their state when paused on a breakpoint in a composable, so you can more easily identify what changes might have caused the recomposition.
  • New Power Profiler, which shows highly accurate power consumption from the device segmented by each sub-system.
  • (Beta) Device Explorer, which now includes information about debuggable processes running on connected devices and actions you can perform on them.
  • (Beta) Compose animation preview, now supports a number of additional Compose APIs and new pickers that let you set non-enum or boolean states to debug your Compose animation using precise inputs.
  • Embedded Layout Inspector, which runs Layout Inspector directly embedded in the Running Device Window in Android Studio, leading to a more seamless debugging experience and significant performance improvements.
  • Firebase Test Lab support for Gradle Managed Devices, which leverages GMD to help you seamlessly configure Firebase Test Lab devices for your automated testing, and now with additional support for smart sharding.

IntelliJ

  • IntelliJ Platform Update to the IntelliJ 2023.1 platform release, which includes a number of performance and quality of life improvements.
  • New UI update that allows Android Studio to adopt a number of improvements to IntilliJ’s modern design language.

See the Android Studio Preview release notes and the Android Emulator release notes for more details.


Download Android Studio Today!

You can download Android Studio Hedgehog Canary or Android Studio Giraffe Beta today to incorporate the new features into your workflow. You can install them side by side with a stable version of Android Studio by following these instructions. The Beta release is near stable release quality, but bugs might still exist, and Canary features are leading edge features. As always, we appreciate any feedback on things you like or features you would like to see. If you find a bug, please report the issue and also check out known issues. Remember to also follow us on Twitter, Medium, or YouTube for more Android development updates!