TAKESHI HAGIKURA: Hello, everyone.
I'm Takeshi from the Android developer relations team.
Today I'm going to show you an experimental feature
that we are working on called Live Edit that
allows you to improve the development
workflow with Jetpack Compose.
With Live Edit, changes you make inside your composable
show up instantaneously on your emulator, physical device,
and the Compose preview.
Let's look at how Live Edit works in an actual project.
Here, I have created a project using the Empty Compose
Activity template in Android Studio Electric Eel Canary.
Let's run the application.
You can see the running application in the emulator.
We launched the Live Edit of literals with Arctic Fox
to enable you to make changes to strings and other materials
and to see those applied automatically
on devices and the preview.
It was useful, but you couldn't do something
like add a modifier to a text.
Live Edit in Android Studio Electric Eel Canary
replaces Live Edit of materials and enables
you to change anything in the function body.
You can even add composables or move them around
within the function body and watch
the changes live on device.
For example, let's change the Greeting function as follows.
I changed the layout using column and row,
added a button next to the text, applied paddings
by adding a modifier, and changed the color
by grouping them by surface.
As you can see, all the changes are automatically
applied to the emulator and the preview
while the app remains running.
When you edit the function body, keep an eye
on the Live Edit UI indicator.
If you see a paused icon next to the Live Edit UI indicator,
it means that Android Studio failed
to update the application.
While you are editing a line of code,
it is quite likely that the file can't be compiled.
As you type, Live Edit is temporarily paused
until you fully complete typing and the file is error free.
If errors persist, you can see more detailed error logs
by hovering your mouse cursor on the Live Edit UI indicator.
Also, if you make a change that is not supported by Live Edit--
for example, adding a new parameter to the function--
Live Edit will stop and you will have to rerun the app
or apply changes to deploy the updates.
The changes are applied instantly
to both the device and the preview.
When you work on a larger application,
Live Edit may take longer to deploy changes.
When that happens, you will see an in-progress spinner
in the Live Edit UI indicator.
Another important point to keep in mind
is that Live Edit currently does not
support partial recomposition.
This means that if your app has navigation,
a code change made to a composable in a specific screen
may require you to navigate back to that screen in the running
instance of the app.
Let's see how you can start to use Live Edit.
First, you will need an Android Studio Electric Eel
Canary or later.
Second, enable Live Edit by opening Android Studio Settings
and enabling the experimental checkboxes for Preview and/or
Device.
Live Edit is an optional feature in Electric Eel Canary,
and we are actively working on it.
And we look forward to getting your feedback.
Finally, you have to run it on the physical device
or on an emulator with API level 30 or higher.
That's it.
You will see that Live Edit is enabled
by looking at the Live Edit green checkmark
state when you run the Jetpack Compose project.
Also, you will see a Live Edit indicator when
you open the Compose preview.
Although we believe Live Edit will improve
the developmental iteration cycle,
there are some limitations because the feature
is at an early stage.
Live Edit only supports editing within the function body.
That means changing the function name
or its parameters won't compile.
Similarly, adding other functions or fields
outside of a function won't compile,
even if they are related to the composable you are viewing.
We are focused on making sure the experience of live editing
within the function body is brilliant before expanding Live
Edit to support other changes.
So we'd love to have you try it out in your project
and help us to improve it by submitting feedback
from the Help menu in Android Studio.
You can also check out the detailed document
about how Live Edit works at developer.android.com.
Make sure to subscribe to the channel
so that you can stay up to date on the latest Android
development updates.
See you next time.
[MUSIC PLAYING]