Posted by Kateryna Semenova, DevRel Engineer; Rahul Ravikumar, Software Engineer; Chris Craik, Software Engineer
A lot of apps find correlation between app performance and user engagement. People expect apps to be responsive and fast to load. Startup time is one of the major metrics for app performance and quality.
Some of our partners have already invested a lot of time and resources for app startup optimizations. For example, check out the Facebook story.
In this blog post we’ll discuss Baseline Profiles and how they improve app and library performance, including startup time by up to 40%. While this blogpost focuses on startup, baseline profiles also significantly improve jank as well.
Android 9 (API level 28) introduced ART optimizing profiles in Play Cloud to improve app startup time. On average, we’ve seen that apps' cold starts are at least 15% faster across a variety of devices when Cloud Profiles are available.
When the app is first launched after install or update, its code runs in an interpreted mode until it is JITted. In an APK, Java and Kotlin code is compiled as dex bytecode, but not fully compiled to machine code (since Android 6), due to the cost of storing and loading fully compiled apps. Classes and methods that are frequently used in the app, as well as those used for app startup, are recorded into a profile file. Once the device enters idle mode, ART compiles the apps based on these profiles. This speeds up subsequent app launches.
Starting with Android 9 (API level 28), Google Play also provides Cloud Profiles. When an app runs on a device, the profiles generated by ART are uploaded by the Play Store app and aggregated in the cloud. Once there are enough profiles uploaded for an application, the Play app uses the aggregated profile for subsequent installs.
While Cloud Profiles are great when they are available, they aren't always ready to be used when an app is installed. Collecting and aggregating the profiles usually takes several days, which is a problem when many apps update on a weekly basis. Many users will install an update before the Cloud Profile is available. The Google Android team started looking for other ways to improve the latency of profiles.
Baseline Profiles are a new mechanism to provide profiles which can be used on Android 7 (API level 24) and higher. A baseline profile is an ART profile generated by the Android Gradle plugin using a human readable profile format that can be provided by apps and libraries. An example might look like this:
HSPLandroidx/compose/runtime/ComposerImpl;->updateValue(Ljava/lang/Object;)V HSPLandroidx/compose/runtime/ComposerImpl;->updatedNodeCount(I)I HLandroidx/compose/runtime/ComposerImpl;->validateNodeExpected()V PLandroidx/compose/runtime/CompositionImpl;->applyChanges()V HLandroidx/compose/runtime/ComposerKt;->findLocation(Ljava/util/List;I)I
Example for Compose library.
The binary profile is stored in a specific location in the APK assets directory (assets/dexopt/baseline.prof).
Baseline Profiles are created during build time, shipped as part of the APK to Play, and then sent from Play to users when an app is downloaded. They fill the gap in the ART Cloud Profile pipeline, when Cloud Profiles are not yet available, and automatically merge with Cloud Profiles when they are.
This diagram displays the baseline profile workflow from creation through end-user delivery.
One of the biggest benefits of Baseline Profiles is that they can be developed and evaluated locally so developers can see realistic end-user performance improvements. They are also supported on a lower version of Android(7 and higher) than Cloud Profiles, which are only available starting in Android 9.
In early 2021, Google Maps switched from a two-week to a one-week release cycle. More frequent updates meant more frequently discarding local pre-compilation, and more users experiencing slow launches without Play Cloud Profiles. By using Baseline Profiles, Google Maps improved their average startup time by 30% and saw a corresponding increase in searches by 2.4%, an immense gain for such an established app.
Code in a library is just like that of an app - it's not fully compiled by default, which can be a problem if it does significant work on the critical path of startup.
Jetpack Compose is a UI library that is not a part of the Android system image and thus not fully compiled when installed, unlike much of the Android View toolkit code. This was causing performance problems, especially for the first few cold launches of the app.
To solve this problem, Compose uses profile installer. It ships baseline profile rules which reduce startup time and jank in Compose apps.
Google PlayStore’s search results page has been re-written with Compose. After incorporating the Baseline Profile rules from Compose, time to render the initial search results page with images improved by ~40%.
The Android team has also added Baseline Profiles to relevant AndroidX libraries. This benefits all Android apps using these libraries. Constraint Layout has found shipping profile rules reduces animation frame times by more than one millisecond.
Create a custom Baseline Profile
All apps and library developers can benefit from including Baseline Profiles. Ideally, developers create profiles for their most critical user journeys to ensure that those journeys have consistently fast performance regardless of whether cloud profiles are available. Check out the detailed guide on how to set up Baseline Profiles for both app and library developers.
Update dependencies
If you are not ready to generate Baseline Profiles for your app right now, you can still benefit from them by updating your dependencies. If you build with Android Gradle Plugin 7.1.0-alpha05 or newer, you'll get Baseline Profiles included in your APK that are already provided by libraries (such as Jetpack). Google Play compiles your app with these profiles at install time. You can supplement these profiles as part of building your application.
Measure Improvements
Don’t forget to measure improvements. Follow the steps on how to measure startup with the generated profile locally.
Provide feedback
Please share your feedback and let us know your experience!
Posted by Madan Ankapura, Product Manager
Today we’re announcing the availability of version 1.2 beta of the Car App Library, enabling app developers to start building their navigation, parking, and charging apps for Android Automotive OS.
Now, developers can begin building and testing apps for these categories using the Automotive OS emulator across both Android Automotive OS and Android Auto. For the entire list of changes in v1.2 beta, please see the release notes. To start building your app for the car, check out our updated developer documentation, car quality guidelines, and design guidelines.
As announced earlier, drivers of Polestar 2 and Volvo cars can now download charging (ChargePoint, PlugShare), parking (Spothero, Parkwhiz), and navigation (Flitsmeister, Sygic) apps developed with the Car App Library by joining the Google Group and opting-in to each app's beta on the Google Play store, with your Gmail account.
Car App Library apps on Android Automotive OS are automatically rendered to be consistent with the rest of the experience within each car, without additional work needed from developers.. For example,
Experience for yourself how your app will look within the different systems, by accessing the OEM emulator system images downloadable in Android Studio. You can begin developing your charging, parking and navigation apps for Android Automotive OS today, and we are working to enable you to publish your apps to the Google Play store in the coming months (stay tuned!).
Beyond navigation, rideshare drivers spend a lot of time in their vehicles and will benefit from safer interactions if those apps can be brought to the car’s screen. We are working with Lyft and Kakao Mobility to bring their driver app experiences into the car in the coming months.
We are also pleased to announce that we are expanding support to all Points of Interest apps. Beyond charging and parking, this allows any app that will help users discover and search for interesting locations on a map, and optionally enable them to navigate to such points. We are partnering with MochiMochi, Fuelio, Prezzi Benzina, and NAVITIME JAPAN as our early access partners.
If you’re interested in joining our Early Access Program in the future, please fill out this interest form. You can get started with the Android for Cars App Library today, by visiting g.co/androidforcars.
Posted by Anna Bernbaum, Associate Product Manager
Last year we announced the Wear Tiles API. To complement that Java API, we are excited to announce that support for Wear OS Tiles has been added to Glance, a new framework built on top of Jetpack Compose designed to make it easier to build for surfaces outside your app on Android. We'd love to get your feedback on this alpha version.
Tiles provide Wear OS users easy access to the information and actions they need in order to get things done quickly. They also are one of the most used surfaces on Wear OS. Just one swipe away from the Watch Face, users can quickly access the most important information or actions from an app, like start a timer or get the latest weather forecast.
Let's see how we can create a Tile with Glance:
class HelloTileService : GlanceTileService() { @Composable override fun Content() { Text(text = "Hello Glance") } }
The simple code above generates the Tile below.
“Hello Glance” Tile sample with Glance
Note: Using Glance-wear-tiles requires`minSdkVersion`>= 26.
`minSdkVersion`
Glance creates “glanceable” experiences across Android surfaces using a base-set of Composables. For Tiles on Wear OS, Glance translates Composables into Tiles.
Diagram: Glance structure
Glance requires Compose to be enabled and depends on Runtime, Graphics, and Unit UI Compose layers, but it’s not directly interoperable with other existing Jetpack Compose UI elements, like Compose for Wear OS.
This initial release introduces the main APIs to build wear Tiles:
GlanceTileService
Content()
Box
Row
Column
Text
Image
Spacer
CurvedRow
CurvedText
GlanceModifier
androidx.compose.ui.Modifier
actionStartActivity
TimelineMode.SingleEntry
TimelineMode.TimeBoundEntries
GlanceStateDefinition
LocalTimeInterval
LocalState
We are working on bringing even more functionality with default theming, further Android Studio support, and more. Stay tuned for new releases.
For a quick start, take a look at the samples in the AndroidX repository. Glance works with the latest stable Android Studio, although since Glance relies on Compose Runtime, follow the steps on the Jetpack Compose docs to set it up first.
The Alpha version is your opportunity to influence the APIs, so please share your feedback and let us know your experience!
Happy Composing with Glance!
Posted by Adarsh Fernando, Product Manager, Android
The Android Studio team has been abuzz with the stable release of Android Studio Bumblebee (2021.1.1) 🐝 and Android Gradle plugin (AGP) 7.1.0; the latest versions of Android official IDE and build system. We’ve improved functionality across a broad area of the typical developer workflow: Build and Deploy, Profiling and Inspection, and Design.
Some notable additions include a unified test execution between Android Studio and your continuous integration (CI) server ✅, convenient pairing flows to support ADB over Wi-Fi 📲, Improved Profiler tools to help you identify and analyze jank in your app 🕵️, and new ways to preview animations 🎥 and UI interactions without deploying your app to a device.
As always, this release wouldn’t be possible without the early feedback from our Preview users. So read on or watch below for further highlights and new features you can find in this stable version. If you’re ready to jump in and see for yourself, head over to the official website to download Android Studio Bumblebee (2021.1.1).
Below is a full list of new features in Android Studio Bumblebee (2021.1.1), organized by the three major themes.
Device Manager
Pairing a device with ADB over Wifi
Using different runners lead to inconsistent results
Android Studio now runs instrumentation tests via Gradle
Detailed frame lifecycle information in the CPU Profiler
<profileable>
<profileable android:shell="true"/>
Inspect Jobs, Alarms, and Wakelocks in the Background Task Inspector
*.li
Interact with the Compose Preview to validate behavior
Preview your animated vector drawables
To recap, Android Studio Bumblebee (2021.1.1) includes these new enhancements & features:
Posted by Arjun Dayal, Group Product Manager, Google Play Games
In December, we announced that Google Play Games will be coming to PCs. As part of our broader goal to make our products and services work better together, this product strives to meet players where they are and give them access to their games on as many devices as possible. We're excited to announce that we’ve opened sign-ups for Google Play Games as a beta in Korea, Taiwan, and Hong Kong.
Users participating in the beta can play a catalog of Google Play games on their Windows PC via a standalone application built by Google. We’re excited to announce that some of the most popular mobile games in the world will be available at launch, including Mobile Legends: Bang Bang, Summoners War, State of Survival: The Joker Collaboration, and Three Kingdoms Tactics, which delight hundreds of millions of players globally each month.
This product brings the best of Google Play to more laptops and desktops, enabling immersive and seamless gameplay sessions between a phone, tablet, Chromebook, and Windows PC. Players can easily browse, download, and play their favorite mobile games on their PCs, while taking advantage of larger screens with mouse and keyboard inputs. No more losing your progress or achievements when switching between devices, it just works with your Google Play Games profile! Play Points can also be earned for Google Play Games activity on PCs.
We’re thrilled to expand our platform for players to enjoy their favorite Android games even more. To sign up for future announcements, or to access the beta in Korea, Taiwan, and Hong Kong, please go to g.co/googleplaygames. If you’re an Android developer looking to learn more about Google Play Games, please express interest on our developer site. We’ll have more to share on future beta releases and regional availability soon.
Posted by Dan Galpin, Developer Relations Engineer
In October of 2021 we released the final unit of Android Basics in Kotlin, our free, self-paced programming course that makes Android development accessible to everyone. It teaches people with no programming experience how to build Android apps. Along the way, students learn the fundamentals of programming and the basics of the Kotlin programming language.
In response to feedback from educators and learners, we've continued to iterate on our course material, adding projects that allow you to apply learnings along with new topics that can prepare students for more advanced material.
With these updates, Android Basics in Kotlin now covers the key material covered in Android Kotlin Fundamentals, so we will be sunsetting the latter course. More advanced learners are encouraged to work through the Basics material, skipping sections that they are familiar with and moving straight to quizzes. Focusing on basics means that intermediate and advanced learners that might be missing a key concept will have what they need to succeed with this material. This also allows our team to focus on making sure our courseware continues to represent our most recent guidance. In addition to courseware, we're continuing to provide codelabs, code samples, documentation, and video content to serve learners at all levels.
Our team is hard at work on the next course that will teach people how to program Android applications using Jetpack Compose. We're looking forward to teaching Android’s modern toolkit for building native UI because of all the ways that it simplifies and accelerates Android UI development.
Taking the current course will teach you the fundamentals of app development, serving as a great starting point should you want to explore the existing Jetpack Compose Learning Pathway, or jump into the upcoming Android Basics with Compose course. You'll have a foundation that you can build on as you continue to explore the world of Android development. Both versions of Android Basics are planned to coexist, giving the option of learning Android with either UI toolkit.
Whether you’ve never built an app before but want to learn how, or just want to brush up on some of our latest best practices, check out the Android Basics in Kotlin course.