Tag Archives: Platform_Update

13 Things to know for Android developers at Google I/O!

Posted by Maru Ahues Bouza, Director of Android Developer Relations

Android I/O updates: Jetpack, Wear OS, etc 

There aren’t many platforms where you can build something and instantly reach billions of people around the world, not only on their phones—but their TVs, cars, tablets, watches, and more. Today, at Google I/O, we covered a number of ways Android helps you make the most of this opportunity, and how Modern Android Development brings as much commonality as possible, to make it faster and easier for you to create experiences that tailor to all the different screens we use in our daily lives.

We’ve rounded up the top 13 things to know for Android developers—from Jetpack Compose to tablets to Wear OS and of course… Android 13! And stick around for Day 2 of Google I/O, when Android’s full track of 26 technical talks and 4 workshops drop. We’re also bringing back the Android fireside Q&A in another episode of #TheAndroidShow; tweet us your questions now using #AskAndroid, and we’ve assembled a team of experts to answer live on-air, May 12 at 12:30PM PT.


MODERN ANDROID DEVELOPMENT

#1: Jetpack Compose Beta 1.2, with support for more advanced use cases

Android’s modern UI toolkit, Jetpack Compose, continues to bring the APIs you need to support more advanced use cases like downloadable fonts, LazyGrids, window insets, nested scrolling interop and more tooling support with features like LiveEdit, Recomposition Debugging and Animation Preview. Check out the blog post for more details.

Jetpack Compose 1.2 Beta  

#2: Android Studio: introducing Live Edit

Get more done faster with Android Studio Dolphin Beta and Electric Eel Canary! Android Studio Dolphin includes new features and improvements for Jetpack Compose and Wear OS development and an updated Logcat experience. Android Studio Electric Eel comes with integrations with the new Google Play SDK Index and Firebase Crashlytics. It also offers a new resizable emulator to test your app on large screens and the new Live Edit feature to immediately deploy code changes made within composable functions. Watch the What’s new in Android Development Tools session and read the Android Studio I/O blog post here.

#3: Baseline Profiles - speed up your app load time!

The speed of your app right after installation can make a big difference on user retention. To improve that experience, we created Baseline Profiles. Baseline Profiles allow apps and libraries to provide the Android runtime with metadata about code path usage, which it uses to prioritize ahead-of-time compilation. We've seen up to 30% faster app startup times thanks to adding baseline profiles alone, no other code changes required! We’re already using baseline profiles within Jetpack: we’ve added baselines to popular libraries like Fragments and Compose – to help provide a better end-user experience. Watch the What’s new in app performance talk, and read the Jetpack blog post here.

Modern Android Development 

BETTER TOGETHER

#4: Going big on Android tablets

Google is all in on tablets. Since last I/O we launched Android 12L, a release focused on large screen optimizations, and Android 13 includes all those improvements and more. We also announced the Pixel tablet, coming next year. With amazing new hardware, an updated operating system & Google apps, improved guidelines and libraries, and exciting changes to the Play store, there has never been a better time to review your apps and get them ready for large screens and Android 13. That’s why at this year’s I/O we have four talks and a workshop to take you from design to implementation for large screens.


#5: Wear OS: Compose + more!

With the latest updates to Wear OS, you can rethink what is possible when developing for wearables. Jetpack Compose for Wear OS is now in beta, so you can create beautiful Wear OS apps with fewer lines of code. Health Services is also now in beta, bringing a ton of innovation to the health and fitness developer community. And last, but certainly not least, we announced the launch of The Google Pixel Watch - coming this Fall - which brings together the best of Fitbit and Wear OS. You can learn more about all the most exciting updates for wearables by watching the Wear OS technical session and reading our Jetpack Compose for Wear OS announcement.

Compose for Wear OS 

#6: Introducing Health Connect

Health Connect is a new platform built in close collaboration between Google and Samsung, that simplifies connectivity between apps making it easier to reach more users with less work, so you can securely access and share user health and fitness data across apps and devices. Today, we’re opening up access to Health Connect through Jetpack Health—read our announcement or watch the I/O session to find out more!

#7: Android for Cars & Android TV OS

Android for Cars and Android TV OS continue to grow in the US and abroad. As more users drive connected or tune-in, we’re introducing new features to make it even easier to develop apps for cars and TV this year. Catch the “What’s new with Android for Cars” and “What's new with Google TV and Android TV” sessions on Day 2 (May 12th) at 9:00 AM PT to learn more.

#8: Add Voice Across Devices

We’re making it easier for users to access your apps via voice across devices with Google Assistant, by expanding developer access to Shortcuts API for Android for Cars, with support for Wear OS apps coming later this year. We’re also making it easier to build those experiences with Smarter Custom Intents, enabling Assistant to better detect broader instances of user queries through ML, without any NLU training heavy lift. Additionally, we’re introducing improvements that drive discovery to your apps via voice on Mobile, first through Brandless Queries, that drive app usage even when the user hasn’t explicitly said your app’s name, and App Install Suggestions that appear if your isn’t installed yet–these are automatically enabled for existing App Actions today.


AND THE LATEST FROM ANDROID, PLAY, AND MORE:

#9: What’s new in Play!

Get the latest updates from Google Play, including new ways Play can help you grow your business. Highlights include the ability to deep-link and create up to 50 custom listings; our LiveOps beta, which will allow more developers to submit content to be considered for featuring on the Play Store; and even more flexibility in selling subscriptions. Learn about these updates and more in our blog post.

#10: Google Play SDK Index

Evaluate if an SDK is right for your app with the new Google Play SDK index. This new public portal lists over 100 of the most widely used commercial SDKs and information like which app permissions the SDK requests, statistics on the apps that use them, and which version of the SDK is most popular. Learn more on our blog post and watch “What’s new in Google Play” and “What’s new in Android development tools” sessions.

#11: Privacy Sandbox on Android

Privacy Sandbox on Android provides a path for new advertising solutions to improve user privacy without putting access to free content and services at risk. We recently released the first Privacy Sandbox on Android Developer Preview so you can get an early look at the SDK Runtime and Topics API. You can conduct preliminary testing of these new technologies, evaluate how you might adopt them for your solutions, and share feedback with us.

#12: The new Google Wallet API

The new Google Wallet gives users fast and secure access to everyday essentials across Android and Wear OS. We’re enhancing the Google Wallet API, previously called Google Pay Passes API, to support generic passes, grouping and mixing passes together, for example grouping an event ticket with a voucher, and launching a new Android SDK which allows you to save passes directly from your app without a backend integration. To learn more, read the full blog post, watch the session, or read the docs at developers.google.com/wallet.

#13: And of course, Android 13!

The second Beta of Android 13 is available today! Get your apps ready for the latest features for privacy and security, like the new notification permission, the privacy-protecting photo picker, and improved permissions for pairing with nearby devices and accessing media files. Enhance your app with features like app-specific language support and themed app icons. Build with modern standards like HDR video and Bluetooth LE Audio. You can get started by enrolling your Pixel device here, or try Android 13 Beta on select phones, tablets, and foldables from our partners - visit developer.android.com/13 to learn more.

That’s just a snapshot of some of the highlights for Android developers at this year’s Google I/O. Be sure to watch the What’s New in Android talk to get the landscape on the full Android technical track at Google I/O, which includes 26 talks and 4 workshops. Enjoy!

Google I/O 2022: What’s new in Android Development Tools

Posted by Juan Sebastian Oviedo, Senior Product Manager

Blue Android Studio 

Today at Google I/O 2022, we announced an exciting set of new features available in Android Studio Dolphin Beta and Electric Eel Canary, both available for download. You told us that you want to be more productive while creating Android apps, so we focused on improvements that make the development experience faster and more informative.

In the Android Studio Dolphin release you will find the following features and improvements that you can start using in the Beta channel, which is close to stable quality:

  • View Compose animations and coordinate them with Animation Preview.
  • Define annotation classes to easily include and apply multiple Compose preview definitions at once.
  • Track recomposition counts for your composables in the Layout Inspector.
  • Easily pair and control Wear OS emulators and launch tiles, watch faces, and complications directly from Android Studio.
  • Diagnose app issues faster with Logcat V2.

For even more cutting edge features, you can take a sneak peek at the Android Studio Electric Eel release in the Canary channel:

  • View dependency insights from the new Google Play SDK Index, a public portal with information about popular dependencies/SDKs. If a specific version of a library has been marked as “outdated” by its author, a corresponding Lint warning will appear when viewing that dependency definition. This enables you to discover and update dependency issues during development instead of later when you go to publish your app on the Play Console. You can learn more about this new tool here.
  • See Firebase Crashlytics reports directly in Android Studio using the new App Quality Insights window. The App Quality Insights window allows you to navigate from stack traces into your code with a few simple clicks. The IDE also highlights lines of code in the editor as you're editing files containing recent crashes. This saves you time by presenting actionable crash information from users directly in the IDE, so you can focus on providing your users with the best app experience.
  • Test your app’s UI on representative reference devices using a single resizable Android Emulator. Instead of having to set up emulators specifically for tablets, phones, or desktops, you can use a single resizable emulator and change its configuration without needing to re-deploy to test your app.
  • With the experimental Live Edit feature, make code changes and have those immediately reflected in the Compose Preview and running app on an emulator or physical device.

These features will be promoted to more stable channels once we have your feedback and make improvements, so please try them out.

To see all the new features in action, watch the What’s new in Android Developer Tools session.

Below is a list of key new features and improvements in Android Studio Dolphin:


Jetpack Compose

  • Compose Animation Coordination - See all your animations at once and coordinate them in Animation Preview. You can also freeze a specific animation.
Compose Animation Coordination

Compose Animation Coordination

  • Compose Multipreview Annotations - Define an annotation class that includes multiple Preview definitions and use that new annotation to generate those previews at once. Use this new annotation to preview multiple devices, fonts, and themes at the same time — without repeating those definitions for every single composable.
Multipreview annotations

Multipreview annotations

  • Compose Recomposition Counts in Layout Inspector - View recomposition counts for a Compose app in the Layout Inspector. Recomposition counts and skip counts can optionally be shown in the Component Tree and Attributes panels. Learn more.
Compose Recomposition Counts

Compose Recomposition Counts


Wear OS

  • Wear OS Emulator Pairing Assistant - Using the Wear OS Emulator Pairing Assistant, you can now see Wear Devices in the Device Manager, and pair multiple watch emulators with a single phone. You also don't have to re-pair devices as often because Android Studio remembers pairings after being closed.
Wear OS Emulator Pairing Assistant

Wear OS Emulator Pairing Assistant

  • Wear OS Emulator Side Toolbar - Use Wear-specific emulator buttons that resemble and simulate physical buttons, including main buttons, palm buttons, and tilt buttons.
Wear OS Emulator Side Toolbar

Wear OS Emulator Side Toolbar

  • Wear OS Direct Surface Launch - Create Run/Debug configurations for Wear OS tiles, watch faces, and complications, and launch them directly from Android Studio.
New Wear OS Run/Debug configuration types

New Wear OS Run/Debug configuration types


Development tools

  • Logcat V2 - Rebuilt from the ground up, the new Logcat makes it easier to parse, query, and track logs. Logcat V2 includes new formatting that makes it easier to scan useful information, new split views to allow you to track more at a glance, and a brand new powerful syntax for filtering logs. Learn more.
Logcat V2

Logcat V2

  • Gradle Managed Devices - Describe the virtual devices you need for your automated tests as a part of your build, and let Gradle take care of the rest. From SDK downloading, to device provisioning and setup, to test execution and teardown, Gradle manages the lifecycle of your virtual devices during instrumentation tests. Gradle is also able to apply intelligent functionality, such as snapshot management, test caching, and test sharding to ensure your tests run efficiently, quickly, and consistently. Gradle Managed Devices also introduces a completely new type of device, called the Automated Test Device, which optimizes devices for automated tests, resulting in significant reduction in CPU and memory usage during test execution. Learn more.
Gradle Managed Devices

Gradle Managed Devices

Below is a list of key new features and improvements in Android Studio Electric Eel:

Jetpack Compose

  • Live Edit - Make code changes to Composables in Android Studio and see those changes reflected immediately in the Compose Preview and your emulator or physical device. Live Edit is an opt-in feature that you can enable in Android Studio settings. Learn more.
Live Edit on emulator

Live Edit on emulator

Live Edit on Preview

Live Edit on Preview


Google Play and Firebase

  • SDK Insights - Get Lint warnings for SDKs/libraries that have been marked as outdated by their authors in the Google Play SDK Index. Update outdated dependency versions during development to avoid issues when your app is submitted to the Play Console.
Google Play SDK Index insights

Google Play SDK Index insights

  • App Quality Insights from Firebase Crashlytics - Discover, investigate, and resolve issues reported by Crashlytics in Android Studio and within the context of your local source code. This integration helps reduce friction when navigating from crashes to code (and from code to crash), and surfaces important contextual data about each crash to help you reproduce issues locally.
App Quality Insights from Firebase Crashlytics

App Quality Insights from Firebase Crashlytics


Large Screens

  • Resizable Emulator - Rapidly toggle between representative reference devices to quickly test various application layout states with a single running emulator instance. You can create these emulators by selecting the “Resizable” type in the Device Manager’s “Create device” flow.
Resizable Emulator

Resizable Emulator

  • Visual Linting - Discover and fix your layout issues across different devices (for example, when a button is hidden out of bounds on a larger tablet) by opening the Layout Validation panel. We automatically run your layout to check for Visual Lint issues across different screen sizes.
Visual Linting

Visual Linting


Development Tools

  • Emulated Bluetooth - You can now discover and connect two phone emulators using virtual Bluetooth. This feature is available on Android Emulator 31.3.8 and higher with system image T (API 33). We plan to add more support for creating sample virtual peripherals, such as beacons and heart rate monitors, and integration testing for your Bluetooth features!
Pairing two Android Emulators using Emulated Bluetooth

Pairing two Android Emulators using Emulated Bluetooth

  • Device Mirroring - Minimize the number of interruptions when developing by streaming your device display directly to Android Studio. Device Mirroring gives you the ability to interact with a physical device using the Running Devices window in Studio. To enable this feature, go to Preferences > Experimental and select Device Mirroring. Once enabled, plug in your device and open the Running Devices window to begin streaming your display.
Device Mirroring

Device Mirroring


To recap, these new features and improvements are available in the Android Studio Dolphin Beta, near stable quality:

Jetpack Compose

  • Compose Animation Coordination
  • Compose Multipreview Annotations
  • Compose Recomposition Counts in Layout Inspector

Wear OS

  • Wear OS Emulator Pairing Assistant
  • Wear OS Emulator Side Toolbar
  • Wear OS Direct Surface Launch

Development tools

  • Logcat V2
  • Gradle Managed Devices

These brand new features and improvements are available in the Android Studio Electric Eel Canary:

Jetpack Compose

  • Live Edit

Google Play and Firebase

  • SDK Insights
  • App Quality Insights from Firebase Crashlytics

Large Screens

  • Resizable Emulator
  • Visual Linting

Development tools

  • Emulated Bluetooth
  • Device Mirroring

Getting started

Android Studio Dolphin Beta and Electric Eel Canary are both available for download. You can install them side by side with the current stable version of Android Studio following these instructions. The Beta release is near stable release quality, but bugs might still exist, so, if you do find an issue, please let us know so we can work to fix it. Likewise, if you find an issue or have feedback for the features in the Canary release, please let us know.

We really appreciate your feedback on issues and feature requests. You can follow us—the Android Studio development team—on Twitter and on Medium.

Check out the preview release notes for more details.

Google I/O 2022: What’s new in Jetpack

Posted by Amanda Alexander, Product Manager, Android

Android Jetpack logo on a blue background 

Android Jetpack is a key pillar of Modern Android Development. It is a suite of over 100 libraries, tools and guidance to help developers follow best practices, reduce boilerplate code, and write code that works consistently across Android versions and devices so that you can focus on building unique features for your app.

Most apps in Google Play use Jetpack for app architecture. Today, over 90% of the top 1000 apps use Jetpack.

Here are the highlights of recent updates in Jetpack - an extended version of our What’s New in Jetpack talk for I/O!

Below we’ll cover updates in three major areas of Jetpack:

  1. Architecture Libraries and Guidance
  2. Performance Optimization of Applications
  3. User Interface Libraries and Guidance

And then conclude with some additional key updates.


1. Architecture Libraries and Guidance

App architecture libraries and components ensure that apps are robust, testable, and maintainable.


Data Persistence

Room is the recommended data persistence layer which provides an abstraction layer over SQLite, allowing for increased usability and safety over the platform.


In Room 2.4, support for Kotlin Symbol Processing (KSP) moved to stable. KSP showed a 2x speed improvement over KAPT in our benchmarks of Kotlin code. Room 2.4 also adds built-in support for enums and RxJava3 and fully supports Kotlin 1.6.

Room 2.5 includes the beginning of a full Kotlin rewrite. This change sets the foundation for future Kotlin-related improvements while still being binary compatible with the previous version written in the Java programming language. There is also built-in support for Paging 3.0 via the room-paging artifact which allows Room queries to return PagingSource objects. Additionally, developers can now perform JOIN queries without the need to define additional data structures since Room now supports relational query methods using multimap (nested map and array) return types.

@Query("SELECT * FROM Artist 
    JOIN Song ON Artist.artistName = 
    Song.songArtistName")
fun getArtistToSongs(): Map<Artist, List<Song>>

Relational query methods using multimap return types


Database migrations are now simplified with updates to AutoMigrations, with added support for additional annotations and properties. A new AutoMigration property on the @Database annotation can be used to declare which versions to auto migrate to and from. And when Room needs additional information regarding table and column modifications, the @AutoMigration annotation can be used to specify the inputs.

Database(
  version = MyDb.LATEST_VERSION,
  autoMigrations = {
    @AutoMigration(from = 1, to = 2,
      spec = MyDb.MyMigration.class),
    @AutoMigration(from = 2, to = 3)
  }
)
public abstract class MyDb
    extends RoomDatabase {
  ...

DataStore

The DataStore library is a robust data storage solution that addresses issues with SharedPreferences. To better understand how to use this powerful replacement for many SharedPreferences use cases, you can check out a series of videos and articles in Modern Android Development Skills: DataStore which includes guidance on testing your app’s usage of the library, using it with dependency injection, and migrating from SharedPreference to Proto DataStore.


Incremental Data Fetching

The Paging library allows you to load and display small chunks of data to improve network and system resource consumption. App data can be loaded gradually and gracefully within RecyclerViews or Compose lazy lists.

Paging 3.1 provides stable support for Rx and Guava integrations, which provide Java alternatives to Paging’s native use of Kotlin coroutines. This version also has improved handling of invalidation race conditions with a new return type, LoadResult.Invalid, to represent invalid or stale data. There is also improved handling of no-op loads and operations on empty pages with the new onPagesPresented and addOnPagesUpdatedListener APIs.

To learn more about Paging 3, check out the new, simplified Paging Basics Codelab on the Android Developer site which demonstrates how to integrate the Paging library into an app that shows a list.

GIF showing Paging Basics list 

Defining In Application Navigation Model

The Navigation library is a framework for moving between destinations in an app.

The Navigation component is now integrated into Jetpack Compose via the new navigation-compose artifact which allows for composable functions to be used as destinations in your app.

The Multiple Back Stacks feature has improved to make it easier to remember state. NavigationUI now automatically saves and restores the state of popped destinations, meaning developers can support multiple back stacks without any code changes.

Large screen support was enhanced with the navigation-fragment artifact providing a prebuilt implementation of a two-pane layout in AbstractListDetailFragment. This fragment uses a SlidingPaneLayout to manage a list pane – managed by your subclass – and a detail pane, which uses a NavHostFragment.

All Navigation artifacts have been rewritten in Kotlin and feature improved nullability of classes using generics – such as NavType subclasses.


Opinionated Architecture Guidance

To learn more about how our key architecture libraries work together, you can view a collection of videos and articles covering best practices for modern Android development in a series called Modern Android Development Skills: Architecture.


2. Performance Optimization of Applications

Using performance libraries allows you to build performant apps and identify optimizations to maintain high performance, resulting in better end-user experiences.


Improving Start-up Times

App speed can have a big impact on a user’s experience, particularly when using apps right after installation. To improve that first time experience, we created Baseline Profiles. Baseline Profiles allow apps and libraries to provide the Android run-time with metadata about code path usage, which it uses to prioritize ahead-of-time compilation. This profile data is aggregated across libraries and lands in an app’s APK as a baseline.prof file, which is then used at install time to partially pre-compile the app and its statically-linked library code. This can make your apps load faster and reduce dropped frames the first time a user interacts with an app.

We’ve already started leveraging Baseline Profiles at Google. The Play Store app saw a decrease in initial page rendering time on its search results page of 40% after adopting Baseline Profiles. Baseline profiles have also been added to popular libraries, such as Fragments and Compose, to help provide a better end-user experience. To create your own baseline profile, you need to use the Macrobenchmark library.


Instrumenting Your Application

The Macrobenchmark library helps developers better understand app performance by extending Jetpack’s benchmarking coverage to more complex use-cases, including app startup and integrated UI operations such as scrolling a RecyclerView or running animations. Macrobenchmark can also be used to generate Baseline Profiles.

Macrobenchmark has been updated to increase testing speed and has several new experimental features. It also now supports Custom trace-based timing measurements using TraceSectionMetric, which allows developers to benchmark specific sections of code. Additionally, the AudioUnderrunMetric now enables detection of audio buffer underruns to help understand audible jank.

BaselineProfileRule generates profiles to help with runtime optimizations. BaselineProfileRule works similarly to other macro benchmarks, where you represent user actions as code within lambdas. In the example below, the critical user journey that the compiler should optimize ahead of time is a cold start: opening the app’s landing activity from the launcher.

@ExperimentalBaselineProfilesApi
@RunWith(AndroidJUnit4::class)
class BaselineProfileGenerator {
  @get:Rule
  val baselineProfileRule = BaselineProfileRule()

  @Test
  fun startup() = baselineProfileRule.collectBaselineProfile(
    packageName = "com.example.app"
  ) {
    pressHome()

    // This block defines the app's critical user journey. Here we are
    // interested in optimizing for app startup, but you can also navigate
    // and scroll through your most important UI.
    startActivityAndWait()
  }
}

For more details and a full guide on generating and using baseline profiles with Macrobenchmark, check our guidance on the Android Developers site.

Avoiding UI Stuttering / Jank

The new JankStats library helps you track and analyze performance problems in your app’s UI, including reports on dropped rendering frames – commonly referred to as “jank.” JankStats builds on top of existing Android platform APIs, such as FrameMetrics, but can be used back to API level 16.

The library also offers additional capabilities beyond those built into the platform: heuristics that help pinpoint causes of dropped frames, UI state that provides additional context in reports, and reporting callbacks that can be used to upload data for analysis.

Here’s a closer look at the three major aspects of JankStats:

  1. Identifying Jank: This library uses internal heuristics to determine when jank has occurred, and uses that information to know when to issue jank reports so that developers have information on those problems to help analyze and fix the issues.
  2. Providing UI Context: To make the jank reports more useful and actionable, the library provides a mechanism to help track the current state of the UI and user. This information is provided whenever reports are logged, so that developers can understand not only when problems occurred, but also what the user was doing at the time. This helps to identify problem areas in the application that can then be addressed. Some of this state is provided automatically by various Jetpack libraries, but developers are encouraged to provide their own app-specific state as well.
  3. Reporting Results: On every frame, the JankStats client is notified via a listener with information about that frame, including how long the frame took to complete, whether it was considered jank, and what the UI context was during that frame. Clients are encouraged to aggregate and upload the data as they see fit for analysis that can help debug overall performance problems.

Adding Logging to your App

The Tracing library enables profiling of app performance by writing trace events to the system buffer. Tracing 1.1 supports profiling in non-debug builds back to API level 14, similar to the <profileable> manifest tag which was added in API level 29.


3. User Interface Libraries and Guidance

Several changes have been made to our UI libraries to provide better support for large-screen compatibility, foldables, and emojis.


Jetpack Compose

Jetpack Compose, Android’s modern toolkit for building native UI, has reached 1.2 beta today which has added several features to support more advanced use cases, including support for downloadable fonts, lazy layouts, and nested scrolling interoperability. Check out the What’s New in Jetpack Compose blog post to learn more.


Understanding Window State

The new WindowManager library helps developers adapt their apps to support multi-window environments and new device form factors by providing a common API surface with support back to API level 14.

The initial release targets foldable device use cases, including querying physical properties that affect how content should be displayed.

Jetpack’s SlidingPaneLayout component has been updated to use WindowManager’s smart layout APIs to avoid placing content in occluded areas, such as across a physical hinge.


Drag and Drop

The new DragAndDrop library also helps with new form factors and windowing modes by enabling developers to accept drag-and-drop data – both from inside and outside their app. DrapAndDrop includes a consistent drop target affordance and it supports back to API level 24.

Drag and drop sample GIF 

Backporting New APIs to Older API Levels

The AppCompat library allows access to new APIs on older API versions of the platform, including backports of UI features such as dark mode.

AppCompat 1.4 integrates the Emoji2 library to bring default support for new emoji to all text-based views supported by AppCompat on API level 14 and above.

Custom locale selection is now supported back to API level 14. This feature enables manual persistence of locale settings across app starts, and supports automatic persistence via a service metadata flag. This tells the library to load the locales synchronously and recreate any running Activity as needed. On API level 33 and above, persistence is managed by the platform with no additional overhead.


Other key updates


Annotation

The Annotation library exposes metadata that helps tools and other developers understand your app's code. It provides familiar annotations like @NonNull that pair with lint checks to improve the correctness and usability of your code.

Annotation is migrating to Kotlin, so now developers using Kotlin will see more appropriate annotation targets, including @file.

Several highly-requested annotations have been added with corresponding lint checks. This includes annotations concerning method or function overrides, and the @DeprecatedSinceApi annotation which provides a corollary to @RequiresApi and discourages use beyond a certain API level.


Github

We now have over 100 projects in our GitHub! Several modules are open for developer contributions using the standard GitHub-based workflow:

  • Activity
  • AppCompat
  • Biometric
  • Collection
  • Compose Compiler
  • Compose Runtime
  • Core
  • DataStore
  • Fragment
  • Lifecycle
  • Navigation
  • Paging
  • Room
  • WorkManager

Check the landing page for more information on how we handle pull requests, and to get started building with Jetpack libraries.

This was a brief tour of all the changes in Jetpack over the past few months. For more details on each Jetpack library, check out the AndroidX release notes, quickly find relevant libraries with the API picker and watch the Google I/O talks for additional highlights.

Java is a trademark or registered trademark of Oracle and/or its affiliates.

Second Beta of Android 13

Posted by Dave Burke, VP of Engineering

Android13 Logo

At Google I/O, we talked about everything that’s new for developers, including the second Beta of Android 13, which we’re releasing today for your testing and feedback. Our program of Beta releases is driven by a philosophy of openness and collaboration with you, our community, and your input makes Android a better platform for everyone. Thank you for the feedback you’ve given so far!

In Android 13, we’re continuing to focus on our core themes of privacy and security as well as developer productivity. We’ve added a new permission for sending notifications, a privacy-protecting photo picker, and improved permissions when pairing with nearby devices and accessing media files. We’ve made it easier to support app-specific language settings, match your app’s icons to the user’s selected theme colors, and build with modern standards like HDR video, Bluetooth LE Audio, and MIDI 2.0 over USB. We’re also continuing to make Android an even better OS on tablets and large screens, giving you better tools to take advantage of the 270+ million of these devices in active use. You can read more about Android 13 in our Keyword blog post.

Beta 2 has everything you need to try the Android 13 features, test your apps, and give us your feedback. Just enroll any supported Pixel device here to get Beta 2 and future updates over-the-air. If you’ve already installed an Android 13 preview or Beta build, you’ll automatically get Beta updates.

You can also get Android 13 Beta on select phones, tablets, and foldables from our partners who are working to deliver quality from day one, including ASUS, HMD (Nokia phones), Lenovo, OnePlus, Oppo, Realme, Sharp, Tecno, Vivo, Xiaomi, and ZTE.

Beta  available today

Visit android.com/beta to see the full list of partners, with links to their sites for details on their supported devices and Beta builds, starting with Beta 1. Each partner will handle their own enrollments and support, and provide the Beta updates to you directly.

With Beta 2 we’re just a step away from Platform Stability in June 2022, when we’ll have the final Android 13 SDK and NDK APIs as well as final app-facing system behaviors. Stay tuned, and for more on the timeline and how to get your apps ready for Android 13, visit the Android 13 developer site!

What’s new in Jetpack Compose

Posted by Jolanda Verhoef, Android Developer Relations Engineer, and Anna-Chiara Bellini, Android Toolkit UI Product Manager

blog header featuring Android logos 

It’s been almost a year since Jetpack Compose 1.0 was released, and during this time we've seen the community adopt it with enthusiasm. You’ve told us you’re appreciating the conciseness of the Kotlin syntax and the declarative approach that makes thinking about UI so much faster and easier.

Compose in the Community

We've seen many companies adopt Compose at scale for the newest and boldest features of their apps. For instance, we've worked closely with the Play Store team, who started experimenting with Compose in the very early days, and learned that not only is it more enjoyable, it is beneficial to their developer productivity. They told us that "All new Play Store features are built on top of this framework. Compose has been instrumental in unlocking better velocity and smoother landings for the app." The team at Twitter has been using Jetpack Compose across different parts of the app, and they are reaping the benefits, as "Compose makes it much easier to define our own components and to make their API contracts more explicit, flexible, and intuitive." The Airbnb team adopted Compose as well: "Jetpack Compose is a critical part of our technical strategy. The productivity gains are massive."

We're very glad to see that these teams, who have carefully evaluated Compose in large, complex production environments, are experiencing not just more fun and clarity in their UI development, but broader engineering benefits! And these are just a few examples, because over 100 of the top 1000 apps in the Play Store are now using Compose.

These close collaborations, and listening carefully to feedback from the broader Android community, are always at the heart of our development process and are key to advancing our roadmap. We're now focusing on supporting your more advanced use cases, with new APIs and feature improvements, all together with new tools to make building with Compose easier. We know that Compose fundamentally changes the way UI is built. To help you with the necessary mindset shift, we're publishing more guidance, talks and codelabs on advanced topics, and more in-depth videos so you can write apps that look great and perform great. Here's what is new:

Compose 1.2 beta

Today, we’re releasing the first beta version of Compose 1.2, which includes a lot of features and improvements.

Text improvements

Font Padding

We’ve addressed one of the top-voted bugs in our issue tracker by making includeFontPadding a customizable parameter. We recommend you set this value to false, as this will enable more precise alignment of text within layout. We aim to eventually make this the default value in a future release. Please let us know in the issue above if setting the value to false leads to issues with your app. Additionally, when includeFontPadding is set to false, you can adapt the line height of your Text composable by setting the lineHeightStyle parameter. Combined it can look like this:

an image of multi-line text

Multi-line Text with includeFontPadding set to true (left, current default) vs false (right) and lineHeightStyle.

Text(
 text = myText,
 style = TextStyle(
   lineHeight = 2.5.em,
   platformStyle = PlatformTextStyle(
     includeFontPadding = false
   ),
   lineHeightStyle = LineHeightStyle(
     alignment = Alignment.Center,
     trim = Trim.None
   )
 )
)

Downloadable Fonts

Compose 1.2 also introduces downloadable fonts in Compose. You can use the new APIs for Compose to access Google Fonts asynchronously, even defining fallback fonts, without any complex setup. With downloadable fonts, you can keep your APK size small and improve your user’s system health as multiple apps can share the same font through a provider.

Text Magnifier

Android text provides a magnifier widget, which makes selecting text easier. Compose now supports the text magnifier.

an image of text and maginifer widget

The magnifier is shown when dragging a selection handle to help you see what’s under your finger. Compose 1.1.0 brought the magnifier to selection within text fields, and now Compose 1.2.0 supports magnifier in both text fields and SelectionContainer. The magnifier has also been enhanced to match the precise behavior of the Android magnifier in Views.

Layout features and improvements

Lazy Layouts

Lazy layouts continue to evolve, with the grid APIs LazyVerticalGrid and LazyHorizontalGrid graduating out of experimental, and a new experimental API being added, called LazyLayout, that lets you implement your own custom lazy layouts. Learn more about these APIs in the I/O talk Lazy layouts in Compose.

Interop with CoordinatorLayout

When you embed a scrolling composable in a CoordinatorLayout from the view system, you can now make sure their scroll behaviors are interoperable. This makes the setup of a collapsible toolbar much easier. You can opt-in to this behavior by passing the result of calling the new experimental rememberNestedScrollInteropConnection method into the nestedScroll modifier. Here’s a sample demonstrating this new functionality.

Window insets

The insets library in Accompanist has now graduated to the Compose Foundation library, using the WindowInsets class. Read more about it in our documentation on Integrating Compose with your existing UI.

Window size classes

To make it easier to design, develop and test resizable layouts, we’ve released window size classes - a set of opinionated viewport breakpoints. They are now available in alpha in a new library material3-window-size-class, as part of the Material 3 set of libraries. You can read more about size classes in the Supporting different screen sizes documentation and take a look at a sample implementation in Crane.

Focus on performance

To help you understand and improve your app’s performance, we focused a lot on new performance tooling and guidance. With this, it becomes much easier to understand why and where your app might be lagging.

Starting from Android Studio Dolphin, you can inspect how often composables recompose using the Layout Inspector. Unexpectedly high numbers of recomposition can point you to a composable that could be optimized. In addition, Android Studio Electric Eel now includes a recomposition highlighter, a visual aid to see which composables recompose when. Read more about this new tooling in the What’s new in Android Studio blog.

Layout Inspector showing recomposition count and recomposition highlighter

Layout Inspector showing recomposition count and recomposition highlighter.

Compose changes the way you write your UI at a fundamental level, so there are some best practices that you can adopt to make sure your app is performant. The newly released documentation page suggests how to write and configure your Compose app for best performance. In the I/O talk Common performance gotchas in Jetpack Compose, the Compose team describe common performance mistakes and how to fix them.

Performance is an ongoing area of focus and we’re working hard on improving and extending tooling and guidance. In the meantime, we’d really appreciate your feedback on the work we’ve done so far. Please raise your bugs in the issue tracker or ask your questions on the KotlinLang Slack group.

New tools

On top of improvements, there are also new tooling updates to help you use Compose more effectively. Android Studio Dolphin, now in Beta, brings exciting features for Compose development. Beyond recomposition counts, new tools include Animation Coordination so you can see and scrub through all your animations at once, and the MultiPreview annotation to help you build for multiple screen sizes. To enable you to iterate faster Android Studio Electric Eel (in Canary) brings LiveEdit.

Gif of Android Studio. On left side there is code and the right side there is a celebration text for Android Developers reaching one million subscribers on YouTube.

Check out What's new in Android Development Tools for all the details, and make sure you share your feedback to help shape the tooling support you need for Compose.

Compose for Wear OS

If there is something better than Compose, it is more Compose! So we're very excited to see Compose for Wear OS moving to Beta! Following the same principle as any other Jetpack library, Beta means that it's feature complete and API stable, and you can start building your production-ready apps. Go ahead and watch the talk, and read the blog post!

New and improved guidance

We’ve added and revamped a lot of the guidance on Compose:

Happy Composing!

We hope that you find these new features as exciting as we do. If you haven't started yet, it's time to learn Jetpack Compose and see how it will fit in your team and development process, so that you can experience all the benefits of improved velocity and developer productivity. Happy Composing!

What’s new for Android developers at Google I/O

Cross-posted on the Android Developers blog by Karen Ng, Director, Product Management & Jacob Lehrbaum, Director of Developer Relations, Android & Play

As Android developers, we are all driven by building experiences that delight people around the world. And with people depending on your apps more than ever, expectations are higher and your jobs as developers aren’t getting easier. Today, at Google I/O, we covered a few ways that we’re trying to help out, whether it be through Android 12 - one of the biggest design changes ever, Jetpack, Jetpack Compose, Android Studio, and Kotlin to help you build beautiful high quality apps. We’re also helping when it comes to extending your apps wherever your users go, like through wearables and larger-screened devices. You can watch the full Developer Keynote, but here are a few highlights:

Android 12: one of the biggest design updates ever.

The first Beta of Android 12 just started rolling out, and it’s packed with lots of cool stuff. From new user safety features like permissions for bluetooth and approximate location, enhancements to performance like expedited jobs and start up animations, to delightful experiences with more interactive widgets and stretch overscrolling, this release is one of the biggest design updates to Android ever. You can read more about what’s in Android 12 Beta 1 here, so you can start preparing your apps for the consumer release coming out later this year. Download the Beta and try it with your apps today!

Android 12 visual

Jetpack Compose: get ready for 1.0 in July!

For the last few years, we’ve been hard at work modernizing the Android development experience, listening to your feedback to keep the openness–a hallmark of Android, but becoming more opinionated about the right way to do things. You can see this throughout, from Android Studio, a performant IDE that can keep up with you, to Kotlin, a programming language that enables you to do more with less code, to Jetpack libraries that solve the hardest problems on mobile with backward compatibility.

The next step in this offering is Jetpack Compose - our modern UI toolkit to easily build beautiful apps for all Android devices. We announced Compose here at Google I/O two years ago and since then have been building it in the open, listening to your feedback to make sure we got it right. With the Compose Beta earlier this year, developers around the world have created some truly beautiful, innovative experiences in half the time, and the response to the #AndroidDevChallenge blew our socks off!

With the forthcoming update of Material You (which you can read more about here), we’ll be adding new Material components as well as further support for building for large screens, making it fast and easy to build a gorgeous UI. We’re pressure testing the final bits in Compose and will release 1.0 Stable in July—so get ready!

Android Studio Arctic Fox: Design, Devices, & Developer Productivity!

Android Studio Arctic Fox (2020.3.1) Beta, the latest release of the official powerful Android IDE, is out today to help you build quality apps easier and faster. We have delivered and updated the suite of tools to empower three major themes: accelerate your UI design, extend your app to new devices, and boost your developer productivity. With this latest release you can create modern UIs with Compose tooling, see test results across multiple devices, and optimize debugging databases and background tasks with the App Inspector. We’re also making your apps more accessible with the Accessibility Scanner and more performant with Memory Profiler. And for faster build speeds, we have the Android Gradle plugin 7.0, new DSL, and variant APIs. You can learn more about the Android Studio updates here.

Android Studio Arctic Fox

Kotlin: the most used language by professional Android devs

Kotlin is now the most used primary language by professional Android developers according to our recent surveys; in fact, over 1.2M apps in the Play Store use Kotlin, including 80% of the top 1000 apps. And here at Google, we love it too: 70+ Google apps like Drive, Home, Maps and Play use Kotlin. And with a brand-new native solution to annotation processing for Kotlin built from the ground up, Kotlin Symbol Processing is available today, a powerful and yet simple API for parsing Kotlin code directly, showing speeds up to 2x faster with libraries like Room.

Android Jetpack: write features, not boilerplate

With Android Jetpack, we built a suite of libraries to help reduce boilerplate code so you can focus on the code you care about. Over 84% of the top 10,000 apps are now using a Jetpack library. And today, we’re unpacking some new releases for Jetpack, including Jetpack Macrobenchmark (Alpha) to capture large interactions that affect your app startup and jank before your app is released, as well as a new Kotlin Coroutines API for persisting data more efficiently via Jetpack DataStore (Beta). You can read about all the updates in Android Jetpack here.

Now is the time: a big step for Wear

The best thing about modern Android development is that these tools have been purpose built to help make it easy for you to build for the next era of Android, which is all about enabling devices connected to your phone–TVs, cars, watches, tablets–to work better together.

Starting today, we take a huge step forward with wearables. First, we introduced a unified platform built jointly with Samsung, combining the best of Wear and Tizen. Second, we shared a new consumer experience with revamped Google apps. And third, a world-class health and fitness service from Fitbit is coming to the platform. As an Android developer, it means you’ll have more reach, and you’ll be able to use all of your existing skills, tools, and APIs that make your mobile apps great, to build for a single wearables platform used by people all over the world.

Whether it’s new Jetpack APIs for Wear tailored for small screens and designed to optimize battery life, to the Jetpack Tiles API, so you can create a custom Tile for all the devices in the Wear ecosystem, there are a number of new features to help you build on Wear. And with a new set of APIs for Health and Fitness, created in collaboration with Samsung, data collection from sensors and metrics computation is streamlined, consistent, and accurate–like heart rate to calories to daily distance–from one trusted source. All this comes together in new tooling, with the release of Android Studio Arctic Fox Beta, like easier pairing to test apps, and even a virtual heart rate sensor in the emulator. And when your app is ready, users will have a much easier time discovering the world of Wear apps on Google Play, with some big updates to discoverability. You can read more about all of the Wear updates here.

Tapping the momentum of larger screens, like tablets, Chrome OS and foldables

When it comes to larger screens -- tablets, foldables, and Chrome OS laptops-- there is huge momentum. People are increasingly relying on large screen devices to stay connected with family and friends, go to school, or work remotely. In fact, there are over 250 million active large screen Android devices. Last year, Chrome OS grew +92% year over year–5 times the rate of the PC market, making Chrome OS the fastest growing and the second-most popular desktop OS. To help you take advantage of this momentum, we’re giving you APIs and tools to make optimizing that experience easier: like having your content resize automatically to more space by using SlidingpaneLayout 1.2.0 and a new vertical navigation rail component, Max widths on components to avoid stretched UIs, as well as updates to the platform, Chrome OS, and Jetpack windowmanager, so apps work better by default. You can learn more here.

Google Duo's optimized experience for foldable devices

Google Duo's optimized experience for foldable devices

This is just a taste of some of the new ways we’re making it easier for you to build high quality Android apps. Later today, we’ll be releasing more than 20 technical sessions on Android and Play, covering a wide range of topics such as background tasks, privacy, and Machine Learning on Android, or the top 12 tips to get you ready for Android 12. If building for cars, TVs, and wearables is your thing, we got that covered, too. You can find all these sessions - and more - on the I/O website. Beyond the sessions and news, there’s a number of fun ways to virtually connect with Googlers and other developers at this year’s Google I/O. You can check out the Android dome in I/O Adventure, where you can see new blog posts, videos, codelabs, and more. Maybe even test out your Jetpack Compose skills or take a virtual tour of the cars inside our dome!

What’s new with Wear

Posted by Simon Earnshaw, Group Product Manager

WearOS image

We’re announcing our biggest update yet to the Wear platform, with new features, APIs and tools to help developers create beautiful, high quality wearable experiences. In this blog post we highlight how we’re making it easier to build great apps for Wear, and how you can start working with pre-release versions of these APIs and tools to prepare your app for the new platform.

First things first: tools

The first thing you’ll want to do is download and install Android Studio Arctic Fox Beta, which includes a developer preview of the new Wear system image as well as improved tools for developing and testing Wear apps without a device:

  • Emulator with new Wear system image (preview) - A developer preview of the new Wear system image is now available so that you can use and play with the newest platform updates!
  • Wear app to phone pairing - We’ve made it much simpler to pair Wear emulators with your phone directly from Android Studio, so you can stay in the IDE to develop, test, and iterate. The new pairing assistant guides you step by step through pairing Wear emulators with physical or virtual phones directly in Android Studio! You can start by going to Device Dropdown > Wear OS emulator pairing assistant. Note that this will currently pair with the Wear OS 2 companion, and a Wear companion for the new release will be coming soon. Learn more.
  • Virtual Heart Rate Sensor - The emulator now has a virtual heart rate sensor, including support for the Heart Rate Sensor API, to help you create and test apps that respond differently to activity levels. Make sure you are running at least Android Emulator v30.4.5 downloaded via the Android Studio SDK Manager.
 New Virtual Heart Rate Sensor in the Wear emulator allows the virtual heart rate to be adjusted with a slider bar

We also announced a new watch face design tool built by Samsung. This new tool will make it a breeze to develop watch faces for all devices running Wear, and is coming soon.

New developer documentation and design guidance

In preparation for the new version of Wear we’ve completely revamped our developer site with new API documentation, learning pathways, codelabs and samples. And with Wear soon to feature a completely new consumer experience based on the latest from Material Design, we’ve updated our design guidelines to cover the new design system, UI components, UX patterns, and styles. Learn more.

New Jetpack APIs

From new Jetpack APIs tailored for small (round or square) screens and designed to optimize battery life to the Jetpack Tiles API, we’re adding a number of new features to help you build great Wear experiences, reduce boilerplate code, and write code that works consistently across Wear versions and devices:

  • Tiles - Tiles give users fast, predictable access to the information and actions they rely on most. We’ve now opened up Tiles for developers, and we’ve already been working with several early access partners to add Tiles to their apps. Here are a few coming soon:
New tiles in development from Adidas, Sleep Cycle, Hole 19, Outdooractive, Calm, Flo, and Golfpad

The Tiles API is in alpha and supported on devices running Wear OS 2 and up, so you can create Tiles for all the devices in the Wear ecosystem. Tiles will start to show up on consumer watches with the new platform update. Learn more

  • Task switching and Ongoing Activities - The new version of Wear makes it easy for users to switch back and forth between apps. With a minimal amount of code, you can use the new Ongoing Activities API to let your users return to your app after they’ve navigated away (to start some other task such as music playback) by tapping an activity indicator icon at the bottom of the watch face, double tapping on the the side button, or via the Recents section of the global app launcher. The Ongoing Activities API is now in alpha. Learn more.
3 new ways for users to switch between apps: Activity indicator on the watch face; double tap the watch’s side button; the Global app launcher
  • Health Services - We also announced today the beginning of a health and fitness platform, created in collaboration with Samsung. This platform provides fitness and health data generated from sensors, contextually-aware algorithms, and all-day health monitoring. You can use the APIs to create high quality, powerful fitness and health experiences for wearables with a simpler development experience. The platform handles all the work to manage your hardware and sensors for you, removing one of the biggest challenges in managing it yourself - knowing when to stop work so the battery doesn't drain. The alpha of this Health Services platform is available today. Learn more.
  • Other new APIs - We’ve released several other new APIs in Jetpack to make wearable app development easier, including support for curved text, input, watch faces, complications and remote interactions. You can learn more about these APIs here.

Google Play Store changes

We know that user engagement and discovery of an app is an important part of growing your business, so big updates coming to Google Play will soon make it much easier for users to discover great app experiences on the watch, including using search to easily find apps for the watch, look at the Wear category for app recommendations, and install apps to the watch directly from the phone.

Learn more

We’re excited for the next generation of Wear. To learn more about developing apps for smartwatches, see d.android.com/wear. We’re excited to see what you build!

What’s new in Jetpack

Posted by Florina Muntenescu, Android Developer Advocate

what's new in jetpack image

Android Jetpack is a suite of libraries, tools, and guidance to help developers follow best practices, reduce boilerplate code, and write code that works consistently across Android versions and devices. Today, 84% of the top 1000 apps on Google Play rely on Jetpack.

Here’s a round-up of the latest updates in Jetpack - an extended version of our What’s new in Jetpack talk!

New in Stable

CameraX

The CameraX library provides a unified API surface for accessing camera functionality across OS versions, including device-specific compatibility fixes and workarounds. Some of the latest improvements to the library address common feature requests, including support for adjusting exposure compensation and access to more detailed information about camera state and features. Additionally, camera settings like FPS range can now be changed via Camera2Interop while the camera is running. The library also brings support for the latest device and OS features, including high-dynamic-range preview, zoom ratio controls, and support for Android’s Do Not Disturb mode. Perhaps most importantly, though, the library has continued to address performance, resulting in faster image capture and faster initialization, especially on older devices.

Hilt

Hilt is Jetpack’s recommended dependency injection solution built on top of Dagger. As part of the transition to stable, Hilt’s ViewModel support has moved up into the core Hilt Android APIs and SavedStateHandle has been added as a default dependency available in the ViewModelComponent. Also, Hilt is now integrated with Navigation and Compose: you can obtain an annotated Hilt ViewModel that is scoped to a destination or the navigation graph itself. Developers have already started using Hilt in their apps. Read about their experience in this blog post.

Paging 3.0

The Paging library allows you to load and display small chunks of data to improve

network and system resource consumption. This release features a complete rewrite in Kotlin with first-class support for coroutines and Flow, asynchronous loading with RxJava and Guava primitives, and overall improvements to the repository and presentation layers.

The 3.0 release is a substantial improvement in usability over Paging 2, and the rewrite was planned with partial and staged migrations in mind so that developers can transition on their own schedules. Check out the Paging 3.0 documentation and the Paging 3.0 codelab for details and hands-on experience.

ConstraintLayout and MotionLayout

ConstraintLayout, Jetpack’s flexible system for designing layouts, and MotionLayout, an API aimed at managing motion and widget animation, are now stable. MotionLayout now includes support for foldable devices, image filters, and motion effects. To find out more about what’s new in design tools, check out this Google I/O talk.

Security Crypto

The Security Crypto library allows you to safely and easily encrypt files and SharedPreferences. To encrypt SharedPreferences, create an EncryptedSharedPreferences object with the appropriate key and scheme and then use it like a standard SharedPreferences object.

val prefs: SharedPreferences = EncryptedSharedPreferences.create(
        context,
        "prefs_file_name",
        mainKey,
        prefKeyEncryptionScheme = AES256_SIV,
        prefValueEncryptionScheme = AES256_GCM,
)
// Use the resulting SharedPreferences object as usual.
prefs.edit()
    .putBoolean("show_completed", true)
    .apply()
Fragment

Over the past year, the Fragment library has undergone a major effort to clean up its internal implementation and reduce undocumented behavior, making it easier for developers to follow best practices in their apps and write reliable tests. This lays the groundwork for future improvements to the library, like supporting multiple back stacks in Navigation, and it may require some work to accommodate strict enforcement of API contracts. In practice, you should pay careful attention to your tests after updating the library. Check out the Fragment release notes to see specific cases to watch out for.

Recent releases have also introduced ActivityResult integration, making it possible to register for Activity results from a fragment. Fragment has also added a new FragmentOnAttachListener interface to replace the less-flexible onAttachFragment method. Existing code that overrides this method in Fragment or FragmentActivity will still work, but we’ve deprecated onAttachFragment to help prevent new code from accidentally adopting a less-flexible approach.

// Obtain the fragment manager. May be a childFragmentManager,
// if in a fragment, to observe child attachment.
val fm = supportFragmentManager

val listener = FragmentOnAttachListener {
    fragmentManager, fragment ->
  // Respond to the fragment being attached.
}

fm.addFragmentOnAttachListener(listener)

New in Beta

Once a library is feature complete it moves to Beta for stabilization. At this moment, the APIs change only in response to critical issues or community feedback.

DataStore

DataStore provides a robust data storage solution that addresses the shortcomings of SharedPreferences while maintaining a simple, highly usable API surface. DataStore brings support for best practices like Kotlin coroutines with Flow and RxJava. DataStore allows you to store key-value pairs, via Preference DataStore or typed objects backed by protocol buffers, via Proto DataStore. You can also plug in your own serialization solution, like Kotlin Serialization.

New in Alpha

Alpha libraries are libraries under active development—APIs may be added, changed, or removed, but what’s in the library is tested and should be highly functional.

AppSearch

AppSearch is a new on-device search library which provides high performance and feature-rich full-text search functionality. Compared to SQLite, AppSearch supports multiple world languages, simplifies ranking query results, and offers lower latency for indexing and searching over large datasets.

AppSearch 1.0.0-alpha01 is released with LocalStorage support, which allows your application to manage structured data, called “documents”, and then query over it. Your application defines what the structure looks like using “schema types”. For instance, you can model a Message as a schema type with data such as subject, body, and sender.

Use builders to create documents of a schema type and then add them to storage. Querying for “body:fruit” will retrieve all documents with the term “fruit” in the body of the Message.

In Android S, AppSearch will also offer PlatformStorage so you can share your application’s data with other applications securely, and reduce your application’s binary size by not having to link additional native libraries. This is currently not available in Jetpack because the library doesn’t target the Android S SDK yet.

Centralized storage on Android S+ for integrating into device-wide search

Centralized storage on Android S+ for integrating into device-wide search

Room

Room is the recommended data persistence layer, providing increased usability and safety over the platform.

Room 2.4.0-alpha brings support for auto-migrations. When your database schema changes, you now declare an @AutoMigration and indicate from which version to which version you want to migrate, and Room generates the migrations for you. For more complex migrations, you can still use the Migration class:

@Database(
-   version = 1,
+   version = 2,
    entities = { Doggos.class },
+   autoMigrations = {
+         @AutoMigration (from = 1, to = 2)
+     }
  )
public abstract class DoggosDatabase extends RoomDatabase { }

Room 2.3.0 stable version brings experimental support for Kotlin Symbol Processing which, in our benchmarks of Kotlin code showed a 2x speed improvement over KAPT, as well as built-in support for enums and RxJava3.

Room has also introduced a QueryCallback class—which provides a callback when SQLite statements are executed, to simplify tasks like logging—as well as the new @ProvidedTypeConverter annotation, which allows more flexibility when creating type converters.

WorkManager

The WorkManager library—Android’s recommended way to schedule deferrable, asynchronous tasks that run even if the app exits or the device restarts—has made improvements to reliability with task reconciliation, ensuring all tasks are executed, and a variety of workarounds for specific Android OS versions.

The latest versions of WorkManager feature improved support for multi-process apps, including performance benefits from unifying work request scheduling to a single process and limiting database growth when scheduling many requests.

Version 2.7—now in alpha, which is targeted to the Android S SDK—provides additional support for the platform’s new foreground restrictions. See the Effective Background Tasks on Android talk for more details.

The Background Tasks Inspector is available in Android Studio Arctic Fox, allowing you to easily view and debug WorkManager jobs when using the latest versions of the library:

background tasts inspector

Background Tasks Inspector

Navigation

The Navigation library, Jetpack’s framework for moving between destinations in an app, now provides support for multiple backstacks and simplifies cases where destinations sit at the same depth, such as a bottom navigation bar.

Macrobenchmark

The Macrobenchmark library extends Jetpack’s benchmarking coverage to app startup and integrated behaviors like scrolling performance. The library can be used remotely to track metrics in continuous integration testing or locally with profiling results viewable from Android Studio. Check out the Google I/O talk on all the details:

For developers who’d like to integrate more closely with Google Assistant, the Google Shortcuts library provides a way to expose actions to Google Assistant and other Google Services through the existing ShortcutInfo class.

You can send up to fifteen shortcuts at a time through the ShortcutManager to be shown on Google Assistant, among other services, making them available for voice and other interactions.

To implement this, define a shortcut with an Intent and a capability binding; this binding provides semantically-meaningful information that will help Google services figure out the best way to surface it to users.

// expose a "Cappuccino" action to Google Assistant and other services
ShortcutInfoCompat siCompat =
  ShortcutInfoCompat.Builder(ctx, "id_cappuccino")
    .setShortLabel("Cappuccino")
    .setIntent(Intent(ctx, OrderCappuccino::class.java))
    .addCapabilityBinding(
        "actions.intent.ORDER_MENU_ITEM",
        "menuItem.name",
        asList("cappuccino")
    )
    .build()

ShortcutManagerCompat.pushDynamicShortcut(ctx, siCompat)
EmojiCompat

All user-generated content in your app contains ?, and supporting modern emoji is a key part of making your app ✨! The EmojiCompat library, which supports modern emoji on API 19 and higher, has moved to a new artifact :emoji2:emoji2, which replaces the previous :emoji:emoji artifact. The new emoji2 library adds ? automatic configuration using the AppStartup library (you don't have to add any code ??‍? to display ?‍❄️)!

AppCompat adds emoji2 starting with AppCompat 1.4. If your app uses AppCompat, users will see modern emoji ⭐ without any further configuration. Apps that aren't using AppCompat can add :emoji2:emoji2-views. For custom TextViews, you can support modern emoji by using the helpers in :emoji2:emoji2-views-helpers or by subclassing AppCompat views.

Jetpack Compose

Jetpack Compose is Android’s modern toolkit for building native UI. It simplifies and accelerates UI development on Android. Jetpack Compose is currently in beta, and planned to go stable in July. Many of the libraries listed here, as well as others that you might already be using, have introduced features specifically for integration with Jetpack Compose. Ranging from Activity to ViewModel, Navigation, or Hilt, all of these libraries can make adopting Compose in your app smoother. Find out more about about how to use them from this Google I/O talk:

Form factors

Jetpack makes it easier to work with different form factors, including foldables, large screen devices, and Wear devices. We've introduced new guidelines for large screen development along with improvements to Jetpack libraries such as WindowManager and SlidingPaneLayout. Read all the details in this blog post.

Conclusion

This was a (relatively) quick overview of what’s new in Jetpack. Check out the AndroidX release notes for all the update details of each library and the Google I/O talks for more information on some of them.

What’s new in Android Privacy

Posted by Sara N-Marandi, Product Manager, Android Platform Product

Android privacy

People want an OS and apps that they can trust with their most personal and sensitive information. Privacy is core to Android’s product principles. As shared in the “What’s new in Android Privacy” session, Android 12 continues to expand on this existing foundation by making the platform even more private.

This release will give users more transparency around the data being accessed by apps while providing simple controls to make informed choices. Android is also investing in reducing the scope of permissions so that apps only have access to the data they need for the features they provide. Let’s look at some of these important changes we’ve made in Android 12 to protect user privacy.

Privacy dashboard: Users often tell us that they want to understand what data apps use. With the new Privacy Dashboard, users will have a simple and clear timeline view of the last 24 hour accesses to location, microphone and camera. You can also share more context about your app’s data usage with a new permission intent API in Android 12. The Privacy dashboard will be available to try in Beta 2.

We encourage all developers to review your code and understand data access needs, including those in third-party SDKs, and make sure all accesses have justifiable use cases. To help with that, in Android 11 we added Data access auditing APIs to make it easy for you to audit your current data access. Use the APIs to untangle mapping of your code by tracking which part of your code accesses private data. The Privacy dashboard will be available to try in Beta 2.

Privacy dashboard and location access timeline

Figure 1. Privacy dashboard and location access timeline in the past 24 hours.

Microphone and camera indicators: In Android 12 we’re adding transparency to microphone and camera access. Going forward, users will know in real time when an app accesses their microphone or camera feeds. By simply going into Quick Settings, users can view the apps accessing their data. If the access is unwarranted, users can quickly navigate to the app permission page to revoke permissions.

Developers should review their use of microphone and camera and proactively remove unexpected access. For example, you should ensure that your app does not access these sensors before the user clicks on a feature that needs access. The Microphone and camera indicators will be available to try in Beta 2.

 Microphone and camera indicators and toggles

Figure 2. Microphone and camera indicators and toggles.

Microphone and camera toggles: You may have seen people placing stickers on cameras or plugging audio blockers into their phones. In Android 12, we’re introducing two new controls that allow users to quickly and easily cut off apps’ access to the microphone and camera on the device. To ensure user safety, emergency calls will be exempted.

If an app with permissions attempts to access the microphone or camera but the user has the sensors turned off, the system will display a message to inform the user that they must turn the sensors back on in order to use the app’s features. If your app follows permissions best practices, then you don’t need to do anything different to incorporate the toggle state. The Microphone and camera toggles will be available to try in Beta 2.

Approximate location: Over the last two releases, we’ve made location permission fine grained. First, we separated background and foreground access. Then, we added an “only this time” option to further restrict access to background location. We’re seeing users respond positively to these controls and are choosing them more often. When given the option, users elect to share less through foreground location access about 80% of the time.

In Android 12, we will give users more control over their location data. Users will have a clear choice regarding the precision of location provided to the app by selecting approximate location.

We encourage you to review your use case for location and request ACCESS_COARSE_LOCATION if your features don’t need the user’s precise location. You should also be prepared for users to reduce location precision. Please make sure your app still works when users select approximate. Approximate location will be available to try in Beta 1.

Location permission request dialog with approximate and precise selection

Figure 3. Location permission request dialog with approximate and precise selection

Clipboard read notification: Content copied to the clipboard can contain sensitive information as users frequently copy emails, addresses, and even passwords. Android 12 notifies users every time an app reads from their clipboard. Users will see a toast at the bottom of the screen each time an app calls getPrimaryClip() . The toast won’t appear if clipboard data originates from the same app. You can minimize access by first checking getPrimaryClipDescription() to learn about the type of data in the clipboard. The recommended best practice is to only access the clipboard when the user understands why the access occured. Clipboard read notification will be available to try in Beta 2.

Nearby device permissions: Android 12 minimizes data access by adding a new runtime permission for nearby experiences that do not use location. Up until now, apps such as watch and headphone companion apps required the location permission to scan for nearby Bluetooth devices for pairing. We heard from users and developers that this was confusing and led to granting the permission to access location data when it wasn’t needed. For apps targeting Android 12, you’ll have the option to decouple nearby device discovery from the fine location permission for use cases like pairing devices by using the new BLUETOOTH_SCAN permission and by declaring usesPermissionFlags=neverForLocation . Once the device is paired, apps can use the new BLUETOOTH_CONNECT permission to interact with it. Apps that use Bluetooth scanning for location must still have the location permission. Nearby device permissions will be available to try in Beta 1.

App hibernation: Last year we launched permissions auto-reset. If an app isn’t used for an extended period of time, Android automatically revokes permissions for the app. In the last 14 days permissions were reset for 8.5M apps. This year we’re building on permissions auto-reset by intelligently hibernating apps that have gone unused for an extended period - optimizing for device storage, performance and safety. The system not only revokes permissions granted previously by the user, but it also force-stops the app and reclaims memory, storage and other temporary resources. Users can bring apps out of hibernation simply by launching the app. App hibernation will be available to try in Beta 1.

Android 12 is our most ambitious privacy release to date. Along the way, we have engaged closely with our developer community to build a platform that puts privacy at the forefront while taking into consideration the impact on developers. We thank you for your continued feedback and support in making our platform private and safe for everyone. Learn more about these changes on the developer site.

What’s new in foldables, tablets, and large screens

Posted by Oscar Wahltinez, Developer Relations Engineer, Google

Users are seeing more value in larger screens, and the benefits of doing more with a single device. Apps designed for large screen devices increase those benefits even further.

The ability to fold a screen offers better ergonomics for large devices. When folded, you can fit a tablet-sized screen in your pocket — unlocking utility that was previously unavailable on a portable device. Thinking about our app ecosystem, we’re excited because this is a hardware shift that is driving new expectations around what you can do from a handheld device. We see the demand for larger screens extending to tablets too, which have greatly increased in popularity, given the similar app experience.

Technological breakthroughs and our understanding of ergonomics have played a role in device form factors.

Technological breakthroughs and our understanding of ergonomics have played a role in device form factors.

In this blog post, we'll explain what you should do to prepare your apps for large screens, and how recent updates have made developing your app easier. But first, let’s talk about what we're seeing with large screens — and why you should optimize your app.

Why large screens

There are many ways to use foldable devices, including a number of postures
  illustrated here.

There are many ways to use foldable devices, including a number of postures illustrated here.

Over the past year, we’ve seen device makers release exciting new foldable and tablet devices. Demand has increased as users are doing more than ever from these devices. Altogether, developers can reach more than 250 million active foldables, tablets, and Chromebooks by building for Android large screen devices today. Sales of tablet devices grew 16% in 2020 with analysts expecting more than 400 million Android tablets by 2023, and foldables are redefining what’s possible on premium devices. Android apps can also run on ChromeOS, which is now the second most popular desktop OS.

Large screen ready

Larger screens are changing how users interact with their device. These devices allow you to edit slide decks while looking at notes, look up restaurant recommendations while planning a night out, or watch a video while chatting with friends. Let’s talk about base-level support — features an app must support to be “large screen ready”. There are three main areas of focus when it comes to large screen readiness:

  1. Designing for large screens
  2. Multitasking
  3. Input modes

They’re summarized below, but make sure to check out our large screen app quality guidelines for the full details.

Design for large screens

The first step is to ensure that your app is designed for large screens. To make this easier, we’ve defined specific window size breakpoints and device classes for you to optimize for. Add tablet layouts for displays where the shortest dimension is >600dp, and ensure your apps go edge-to-edge. Developers should also plan for their app to be used in both portrait and landscape modes, since larger screens are more likely to be used in landscape. We’ve got material adaptive components that we’ll be talking about to help developers make better use of the increased space.

Since foldable and large screen devices have a variable window size, adaptive
  layouts work better than splitting experiences based on screen size.

Since foldable and large screen devices have a variable window size, adaptive layouts work better than splitting experiences based on screen size.

Multitasking

Going into split screen (or multi-window mode) and gestures like drag and drop are starting to become natural interactions that users expect to work seamlessly in their large screen devices. Your apps should handle multitasking seamlessly by being resizable. Handling folding and unfolding events and planning for your app to be in multi-window mode prevents your app from becoming letterboxed.

Drag and drop can be a natural interaction in large screen layouts, even within the same
  app.

Drag and drop can be a natural interaction in large screen layouts, even within the same app.

By enabling multiple instance support, users can run multiple copies of your
  app side-by-side. The let’s users compare two products, reference notes
  while writing a document or maybe keeping your calendar in view as you are
  planning an event.

By enabling multiple instance support, users can run multiple copies of your app side-by-side. The let’s users compare two products, reference notes while writing a document or maybe keeping your calendar in view as you are planning an event.

Input modes

Since many people use larger screens for productivity, tablets should support basic keyboard, mouse and stylus usage.

Users of Android apps on ChromeOS devices often have a keyboard; apps should ensure that standard keyboard navigation and shortcuts are available to provide improved accessibility.

Users of Android apps on ChromeOS devices often have a keyboard; apps should ensure that standard keyboard navigation and shortcuts are available to provide improved accessibility.

Component updates

Several UI components across Jetpack and Material Design libraries have been updated to help you build a flexible user experience to scale your phone's UI to a larger screen.

SlidingPaneLayout

One of the most common adaptive layouts to optimize your app for large screens is implementing a list-detail UI. For example, a messaging app that lists messages on one side with the message detail on the other.

SlidingPaneLayout automatically adapts to configuration changes to provide a good user experience across different layout sizes.

SlidingPaneLayout automatically adapts to configuration changes to provide a good user experience across different layout sizes.

UIs that would be one top of each other on a smaller screen can now easily lay out side-by-side. For this, you can use the updated version of the SlidingPaneLayout library — updated to support a two-pane style layout, SlidingPaneLayout uses the width of the two panes to determine how to lay out the UI. It does that by automatically determining if it can lay out side-by-side based on the content width and available space. For example, if the list pane is measured to have a minimum width of 200dp and the detail pane needs 400dp, then the SlidingPaneLayout automatically shows the two panes side by side if it has at least 600dp of width available.

SlidingPaneLayout is used in our sample application IOSched.

SlidingPaneLayout is used in our sample application IOSched.

We have updated the library to recognize and adapt to folds and hinges . For example, if you are on a device with hinges that blocks part of the screen, it will automatically place your content on either side.

We have also introduced lock modes,which allow control over the swipe behavior when panes overlap (programmatically switching is also supported). For example, to prevent users from swiping to an empty pane you may want them to have to click on a list item to load information about that pane, but allow them to swipe back to the list. On a foldable device or tablet that has room to show both views side by side, the lock modes are ignored.

NavRail

A vertical Navigation Rail is functionally equivalent to Bottom navigation, and provides a more ergonomic navigation experience on larger screens. As you scale your UI, NavRail supports better reachability, since larger screens tend to be held by the side, whereas on the phone users are probably holding the device from the bottom.

NavRail automatically changes the location of the navigation menu depending
	on configuration changes.

NavRail automatically changes the location of the navigation menu depending on configuration changes.

For example, NavRail can help if vertical scrolling is key to your app. In those cases, a bottom navigation bar decreases the amount of content that’s visible, especially when tablet devices are being used in landscape orientation.

Other Components

We've also made updates across multiple other components. One of the biggest pitfalls when apps move to a larger screen is when UIs are stretched edge-to-edge across the whole screen. To help prevent this, we’ve added default Max Width values to certain Material Components where this commonly happens, for example:

  • Buttons
  • TextFields
  • Sheets

We will add more components to this list in the future. These changes provide opinionated defaults to help your apps adapt and look better out of the box on large screen devices. Find more information about using size constraints with components in the Material Design guidelines.

Most foreground UI elements should have a maximum width value.

Most foreground UI elements should have a maximum width value.

WindowManager Jetpack library

Beyond component updates to help you scale your UI, we also have the WindowManager Jetpack library to help you build better experiences on these devices. This library is now available in alpha and it provides a common API surface for supporting different device types, starting with foldables and tablets.

You can use WindowManager to detect display features such as folds or hinges. It also gives information about how the display feature affects your app, so you can create an optimal experience. For example, reacting to the foldable device state changes when the device is folded into tabletop mode while the user is watching a video.

Applications should seamlessly adapt to a growing number of device configurations.

Applications should seamlessly adapt to a growing number of device configurations.

WindowManager also provides a couple of convenience methods to retrieve the current and maximum WindowMetrics information in a backward compatible way, starting from API level 14.

Platform changes

Display API deprecations

Your app needs to determine the screen or display size in order to render content appropriately for each device. With the introduction of the WindowMetrics API, a number of methods related to display size have been deprecated. For a backwards-compatible replacement, you should use the Window Manager Jetpack library.

Exclusive resources

Android 10 introduced the possibility to have multiple resumed apps running at the same time, with a single “top resumed” application. Most applications benefit from this change without the need of updates. The most notable exception is if your application uses an exclusive resource like the microphone or the camera. See our previous blog post for more details.

Case studies

Optimizing your app for large screens can improve the experience for your users, as well as deliver on business results. We’re seeing an increased number of apps take advantage of the opportunities with large screens on Google Play. As an example, Google Duo implemented tablet and foldable support to enhance their user experience, and saw an increase in app ratings and user engagement.

Google Duo's optimized experience for foldable devices

Google Duo's optimized experience for foldable devices, such as the Samsung Galaxy Z Fold2

In addition to Google Duo's enhanced user experience, we've modernized many additional apps to use adaptive layouts so they can take advantage of large screens and foldable devices:

  • Chrome added improved tab navigation for larger screens
  • YouTube redesigned its UI to improve usability in foldable devices
  • Google Photos displays more UI elements, like a search bar, in larger screens
  • Google Calendar provides a more ergonomic UI in larger screens


Learn more

To learn more about foldables and large screen devices, see the following resources: