[MUSIC PLAYING]
ADARSH FERNANDO: Hello, everyone.
[APPLAUSE]
You've made it.
It's the last talk of the afternoon, the headliner,
the one you've been all waiting for,
how you can test at scale with Gradle Managed Devices.
My name is Adarsh Fernando.
I'm a product manager for Android developer tools.
And before we get into what our Gradle Managed Devices is
and why you should be using them,
I think we can all take a moment to appreciate that Android
ecosystem is quite diverse, lots of different screen sizes,
form factors, OEMs.
And while that diversity is great for users,
for quality-driven teams who want to catch issues across all
these devices before they hit users,
it can still be a real challenge.
Now, Android emulators does provide a lot of flexibility
and allowing you to create those different types of device
shapes and sizes across different APIs levels.
But properly leveraging them to run scalably
and reliably on your CI is still a challenge.
That's why we've worked on Gradle Managed Devices.
What if you could just describe to Gradle
the devices you want to run your tests on,
and then it tries to do so in a reliable, optimized way
for you?
Let's take a look how that would work.
Well, in the initialization phase,
it creates the devices you ask for,
including downloading SDK components as required.
It creates a zero-state snapshot that it can then
snap the devices back to between test runs for more
consistent test results.
And then as it's running your tests across those devices
in parallel, it's also generating a test cache,
so it can automatically skip tests
that don't need to run again.
Finally, it tears down your devices,
releasing resources back to your workstation for its next job
and then generates the test artifact
that then you can use to open up in a browser
or in Android Studio.
Now, this all sounds great.
How do you get started?
Well, it only takes a couple of lines
in your build.gradle file, starting with the Managed
Devices closure.
And in this closure, we define a device here.
We're defining the Pixel 2 device
that's running API level 31 and uses the AOSP image.
We could use Google if we wanted the Play Store,
but we're going to stick with AOSP.
And just as easily, we can run our tests
on that device using the Android Test
Task modified with the build variant
and the name of the device.
But we want to run the tests on more than one device.
And you can do that.
You can define multiple devices and add them to a device group
and then just as easily run your Android Test Task
against that group.
And Gradle Managed Devices runs your tests
across devices in parallel.
Now, the more devices you add, you're
going to start hitting your memory and CPU limit.
And we're trying to help with that using something
called Automated Test Devices.
This is a new type of device image
which strips out a lot of the apps and overhead
and background processes that developers typically
don't need when they're running their tests on CI.
And this can lead to significant reduction in memory and CPU
usage based on your workstation.
And here, it's just as easy as targeting
that image type, so aosp-atd.
And we only currently support API levels 30 and 31,
but we are adding more along the way.
Now, with the additional resources that you're saving,
you could either run on more device configurations,
or you can even use test sharding to execute
your tests even faster.
Gradle Managed Devices is stable in AGP 7.3.
And 7.4 is in beta with even further stability
and performance improvements.
And we're continually improving that feature.
So please give it a try and provide us feedback.
Now, there's one aspect of testing
on devices we haven't covered.
And what if you need to test on real, physical, OEM
devices for which sometimes there is no substitute?
For that, we're turning to Firebase Test Lab.
And in the latest AGP, you can now
target any of Firebase Test Lab's virtual or physical
devices as a Gradle Managed Device,
so you get the benefits of test caching and seamless
integration that GMD provides now with FTL devices.
So once you're authenticated via gcloud,
you just add the new Firebase Test Lab plugin to your build.
And then you target the Firebase Test Lab device
type in your device definition.
And it's just that easy.
So please give it a try in the latest version of AGP 8.0.
We are continuing to develop this feature,
so any feedback is really welcome.
And that's Gradle Managed Devices,
a feature in Android Gradle plugin
we hope makes it easier, more scalable,
and with the power of Firebase Test Lab for you.
And I think that's my cue to leave.
Thank you so much.
[APPLAUSE]
[MUSIC PLAYING]