How to use Gradle Managed Devices with your own devices

<p>Google recently introduced a new feature for Android Gradle Plugin,&nbsp;Firebase Test Lab for Gradle Managed Devices. It uses&nbsp;Gradle Managed Devices&nbsp;API to launch tests not on the same machine where Gradle runs, but on a remote virtual or physical device inside&nbsp;Firebase Test Lab&nbsp;(paid feature). In this article, we&rsquo;ll cover its functionality, how we can use our own device farm to launch tests remotely in the same manner as Firebase Test Lab does, and parallelize execution between multiple devices.</p> <h1>Gradle Managed Devices</h1> <p>Initially,&nbsp;Gradle Managed Devices&nbsp;was released to delegate a process of creation, launching, and closing emulators to Android Gradle plugin.</p> <pre> android { testOptions { managedDevices { devices { register(&quot;pixel2api30&quot;, com.android.build.api.dsl.ManagedVirtualDevice) { device = &quot;Pixel 2&quot; apiLevel = 30 systemImageSource = &quot;aosp&quot; } } } } }</pre> <p>By using the configuration above, we&rsquo;re able to launch UI tests via&nbsp;<code>pixel2api30Check</code>&nbsp;task, and don&rsquo;t need to connect a device or launch an emulator before running it. The environment of this test run is the same across different machines.</p> <h1>Firebase Test Lab</h1> <p>Firebase Test Lab for Gradle Managed Devices&nbsp;is a new feature, recently presented at&nbsp;Android Dev Summit 2022. This means that we can now run UI tests in Test Lab directly from Gradle, and don&rsquo;t need to use command line tools or web UI.</p> <p><a href="https://medium.com/bumble-tech/how-to-use-gradle-managed-devices-with-your-own-devices-750d6709552d">Website</a></p>
Tags: Devices Gradle