Firebase Test Lab is a cloud-based app-testing infrastructure that lets you test your Android apps across a wide range of devices and configurations. It helps detect bugs and performance issues before releasing your app to users. In this guide, you’ll learn how to set up Firebase Test Lab in Android Studio step by step.

Step 1: Create a Firebase Project
Go to the Firebase Console and create a new project. Give your project a meaningful name and follow the steps until the project is created.
Step 2: Connect Android Studio to Firebase
- Open your Android project in Android Studio.
- Navigate to Tools > Firebase.
- In the Firebase Assistant panel, choose Test Lab and click Set up Firebase Test Lab.
- Connect your app to Firebase by selecting your Firebase project and syncing.
Step 3: Add Required Dependencies
Open your build.gradle (app-level)
file and add the following:
dependencies { androidTestImplementation 'androidx.test:runner:1.5.2' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' }
Make sure you also have this in your build.gradle (project-level)
:
buildscript { dependencies { classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.5' } }
Sync the project after adding dependencies.
Step 4: Create an Instrumentation Test
In androidTest/java/com.yourapp.package
, create a test class:
@RunWith(AndroidJUnit4.class) public class ExampleInstrumentedTest { @Test public void sampleTest() { onView(withText("Hello World")).check(matches(isDisplayed())); } }
Step 5: Run Test with Firebase Test Lab
- Open the Run > Edit Configurations menu.
- Select Android Instrumented Tests.
- Click Test Lab Device Matrix, and select the devices and OS versions you want to test.
- Click Run.
You can also upload tests manually via the Firebase console or gcloud CLI for CI/CD pipelines.
Bonus: Use Firebase CLI for Advanced Test Execution
You can install the Google Cloud SDK and run tests using:
gcloud firebase test android run \ --type instrumentation \ --app app-debug.apk \ --test app-debug-androidTest.apk \ --device model=Pixel2,version=30
Firebase Test Lab is particularly useful for testing on physical devices without having to own them all. For further testing integrations, you can explore Firebase’s documentation on Test Lab.