Search code examples
androidfirebaseadmobfirebase-test-lab

Prevent firebase test labs from clicking ads


I used Firebase Test Lab to test my app before uploading it to Google Play.

Looking at the screenshots and video it looks like real ads are displayed from admob and then clicked on.

Now I know you can set test devices to show test ads but I cannot find any ids for firebase test devices, or can I in code somehow identify that this is a robo test so I can prevent real ads?

Also I wonder if google play pre launch report tests has the same issues?


Solution

  • You can detect if the device is running in Firebase Test Lab in your code by looking for the environment variable firebase.test.lab as documented in the official documentation.

    String testLabSetting = Settings.System.getString(getContentResolver(), "firebase.test.lab");
    if ("true".equals(testLabSetting)) {
        // Do something when running in Test Lab
    }
    

    The same will work for Google Play Pre Launch reports.