TOMAS MLYNARIC: Android Studio Flamingo
version 2022.2.1 is now available for downloading
on the Stable channel.
In this version, you can find improvements
for building beautiful UIs, new features
that help you debug and inspect your apps, and more.
Android Studio Flamingo is based on the IntelliJ IDEA 2022.2
version.
It uses JetBrains Runtime 17, which
introduces performance improvements, better security,
enhanced rendering performance on Mac OS
thanks to the metal API, and more.
It also improves the IDE performance
when using Kotlin, which positively
impacts code highlighting, completion, and find usages.
Let's take a look at all the updates in detail.
We're constantly building out and improving
tooling to develop great UIs. One of the tools
is Live Edit that allows you to iteratively develop
Jetpack Compose apps.
Live Edit works by pushing code changes directly
to an attached device or emulator, which
can improve your productivity by not requiring you to rebuild
the whole project and switch contexts between code,
previews, and devices.
We've introduced Live Edit in the past,
so check out this video if you're new to Live Edit.
In Android Studio Flamingo, Live Edit is still experimental,
but you can enable it by going into Settings, under Editor
Settings, and Live Edit.
We've added options to select whether the changes are pushed
automatically or when manually saving files
so you can now choose the option that best suits your coding
style.
This version of Android Studio also
brings improvements to the project and module templates.
Templates now use Compose Material 3 by default
unless they're specified as views templates.
We recommend using the Compose Material 3 templates,
for example, Empty Activity, as the best practice
for creating an Android app.
Material 3 dynamic color is now also supported
for previewing UI.
To preview dynamic colors in the Compose previews,
just update the preview annotation
by adding the Wallpaper parameter
with one of the options from the wallpapers object,
and see how your UI reacts to different users' chosen
wallpaper.
Note that this feature is only available from Compose
UI tooling 140, so make sure you're
using the latest version.
You can also preview dynamic colors
for your app's launcher icon.
To see this, open the system UI Mode Selector
from the toolbar within the Design pane,
switch the wallpaper, and see how your app
icon reacts to the changes.
And similarly, if your project uses Android views,
you can preview dynamic colors in your UI while previewing
your XML layout.
Next, Android Studio Flamingo adds
support for Compose Composition Tracing.
With this, you can view your Compose functions
in the system tracing profiler and measure how long
each composable took to render.
To get started with Composition Tracing,
add a dependency on runtime tracing, and make sure
you use Compose UI and Compose Compiler 130 or higher.
You also need to trace on a device running
API 30 or higher.
To get realistic data, you should
run the profiler on a physical device with your
build set to Profilable Not Debuggable.
This allows you to inspect your app's performance
with really low overhead, close to what your users would see,
while limiting some capabilities that are only
available with debuggable builds.
In Android Studio Flamingo, we're
introducing a new one click way of launching your app
into profileable mode without the need
to define separate variants in your build configuration.
Just choose a profile with low overhead,
which will build your app and start the profiler.
Alternatively, you can still choose
to profile your debuggable build by selecting
Profile App with Complete Data.
But be aware that the performance might not represent
the real world experience.
Now, to get to Composition Tracing, when the Profiler
window opens, click on the CPU timeline,
select the System Trace, and hit Record.
Interact with your app.
And after you're happy with the recording,
you can click Stop, which will open
the system trace for your app.
Here you can see the timeline with the data I recorded.
We chose all the code composeables
and their duration.
To easily navigate to the code of a composeable
you can just double click the Trace section.
If you're not familiar with the Profileable flag,
or you're new to system tracing, we
recommend checking the linked videos,
which explain in depth how the features work
and how to use them.
Let's continue with features that help you debug and inspect
your apps.
In the previous Android Studio version,
we launched App Quality Insights, a tool that
helps you discover, investigate, and reproduce issues
reported by Crashlytics, all within the context
of your local Android Studio project.
In this version, we're making improvements
based on your feedback that will help you focus on high priority
issues and collaborate with your development team.
To help you identify the most important issues,
we're adding new filters and filter search.
You can now filter by app version, Crashlytics signals,
device types, operating system version, or play track.
To only see production issues within an app,
I uncheck any internal testing tracks, and once loaded,
we can see all open issues ordered by frequency.
Crashlytics provides multiple classifications of issues,
called signals, like an early signal
which denotes issues that happen close to the app start.
You can filter for that, too.
Besides filtering, you can now annotate and close issues
directly from Android Studio.
This helps communicate important information to your team
and let them know when an issue has already been taken care of.
To add a note, open the Notes pane within an issue,
add your required comment, and hit Send.
Then you can close the issue.
Let's hope it won't reappear with a regression signal.
And we packed even more into Android Studio Flamingo.
To help with network requests, we're
introducing a new feature within the Network Inspection tool
that many developers asked for, traffic interception.
With traffic interception, you can create and manage
rules which determine what responses to intercept
and how to modify these responses before they
reach your app.
To get started, navigate to the Rule Stop in the Network
Inspector and click Plus to create a new rule.
In the Rule Details panel, name your new rule
and include information about the origin of the response
you want to intercept.
From the Response subsection, you
can modify response status, headers, or request body.
When you create multiple rules, these
are applied in order that they are listed,
so make sure to reorder them based on your needs.
Let me show you how to apply a rule to a response body now.
You can choose to either find and replace
a section of the body, in which the first found
instance in the body is replaced,
or you can choose to replace the entire content of the body
by selecting Replace Entire Body.
The rules are automatically saved and applied
to any upcoming network request.
Once a rule is defined, trigger a network request
from the app to see the response changed in real time
without the need to rebuild the app.
For the Now In Android app, network requests
are done when the app starts, so I
need to restart it to see it in action.
So here we can see that once the data is loaded,
the response contains more up-to-date information.
The next update is a minor improvement
in the Layout Inspector.
When you open the Layout Inspector,
you no longer have to click to attach it to your app.
It will autoconnect to the foreground process for you.
And finally, for those of you working
on optimizing build times, we've added
build analyzer task categories.
With Android Gradle plugin 8.0 or higher,
instead of displaying Gradle tasks individually,
build analyzer groups then by category.
This way, you can see tasks that are specific, for example,
to Manifest, Android Resources, Kotlin, Dexing, and others.
These categories are sorted by the build duration, which
makes it easy to know what category has the most
impact on build time.
Expanding each category displays a list
of the corresponding tasks so you can further analyze what
was the build time bottleneck.
AGP now also requires JDK 17.
Android Studio Flamingo comes bundled
with a compatible version of the JDK and configures Gradle
to use it by default. But don't forget
to update if you're not using the JDK bundled
with Android Studio.
In this version of AGP, we've changed
the default values for some build
features that were previously applied in each Gradle module.
Features such as buildConfig, renderScript,
or Android Interface Definition Language, or AIDL,
are now disabled by default. If you
need to enable any of these features,
make sure to explicitly set them to True in the
build Gradle files into modules you want to use them.
We've seen these flags are often not used in all Gradle modules,
so this way, we can reduce unnecessary build time.
The next breaking change is that the R classes
are now non-transitive by default for library modules,
and only contain resources defined in the specific library
module.
Please note that you might need to fix import statements
in your project if you are referring
directly to the transitive package name R classes.
Another requirement is that for each module in your app,
you must now provide a namespace property in the build Gradle
file.
This property replaces the package attribute
set in Android manifest, which was previously
used for setting both the application ID
and R class namespace, which was coupling
potentially unrelated concepts.
If you want your test APK to have a different namespace
for the generated R and build Config classes,
you can use the test namespace DSL property.
The AGP Upgrade Assistant now supports these changes
and can help you migrate your project settings.
If possible, use it to ease the migration.
One last thing to mention.
For anyone using the SDK extensions
to leverage the modular system components,
the Link tool can now scan for issues with them.
In addition, Android Studio can auto
generate the correct version checks for APIs that are
launched using SDK extensions.
And that's a wrap for Flamingo.
Download it and start using it today.
You can also try the next version
of Android Studio, Giraffe, which brings even more features
and improvements.
As usual, please provide feedback regarding
any issues on our issue tracker, which
is lined in the description.
Give this video a like if you're excited about the new features,
and subscribe to the channel for future updates.
Happy coding.