<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/find-more-bugs-using-strictmode-with-firebase-test-lab-for-android-qflurrqz7" -->

---
title: Find More Bugs Using StrictMode with Firebase Test Lab...
description: Enabling Android's StrictMode API to catch policy violations like main-thread disk I/O or leaked Activity references, and configuring it to crash the app...
canonical: https://daily.dev/posts/find-more-bugs-using-strictmode-with-firebase-test-lab-for-android-qflurrqz7
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Find More Bugs Using StrictMode with Firebase Test Lab for Android | daily.dev
og:description: Enabling Android's StrictMode API to catch policy violations like main-thread disk I/O or leaked Activity references, and configuring it to crash the app...
og:url: https://daily.dev/posts/find-more-bugs-using-strictmode-with-firebase-test-lab-for-android-qflurrqz7
og:image: https://api.daily.dev/og/posts/QFlURRQZ7.png
og:image:alt: Find More Bugs Using StrictMode with Firebase Test Lab for Android
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Find More Bugs Using StrictMode with Firebase Test Lab for Android

**[Firebase](https://daily.dev/sources/firebase-blog)** · 5 min read · 0 upvotes · 0 comments

## Summary

Enabling Android's StrictMode API to catch policy violations like main-thread disk I/O or leaked Activity references, and configuring it to crash the app fatally so those issues surface as test failures. Explains how to detect when the app is running inside Firebase Test Lab (via a system setting) and enable fatal StrictMode there specifically, so instrumented tests and Robo tests fail loudly and produce log output pinpointing the violation. Also covers when to enable StrictMode at app launch, how to temporarily disable fatal crashing for known library issues, and reading StrictMode violation stack traces in Test Lab reports.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://firebase.blog/posts/2017/07/find-more-bugs-using-strictmode-with>

## Questions this post answers

### How do I make Android StrictMode crash my app only during Firebase Test Lab runs and not in production?

Query the device's system settings for the key firebase.test.lab using Settings.System.getString(resolver, "firebase.test.lab") and enable fatal StrictMode policies when that value equals "true", in addition to when BuildConfig.DEBUG is true. This lets instrumented tests and Robo tests crash and fail visibly on StrictMode violations without affecting real users.

_See how daily.dev surfaces practical Android testing techniques like StrictMode integration for CI pipelines._

### How do I set up StrictMode to crash the app on any policy violation instead of just logging it?

Build a StrictMode.ThreadPolicy and StrictMode.VmPolicy with detectAll(), penaltyLog(), and penaltyDeath(), then apply them via StrictMode.setThreadPolicy() and StrictMode.setVmPolicy(). penaltyDeath() forces an immediate crash on violation instead of merely logging it, which is useful for catching bugs like main-thread disk reads during automated testing.

_Developers hardening Android debug builds can track StrictMode patterns like this through daily.dev._

## Similar posts on daily.dev

- [Prioritizing Memory Efficiency: Essential Steps for Android 17](https://daily.dev/posts/prioritizing-memory-efficiency-essential-steps-for-android-17-zj0b3ibcc) · Android Developers Blog · 1 upvotes · 0 comments
- [Android App Penetration Testing: From APK Decompilation to Runtime Exploitation \[Tools and Labs\]](https://daily.dev/posts/android-app-penetration-testing-from-apk-decompilation-to-runtime-exploitation-tools-and-labs--djuxfgoqa) · InfoSec Write-ups · 0 upvotes · 0 comments
- [Reproduce, Capture, Report: A QA Tester’s Bug Workflow in One macOS App](https://daily.dev/posts/reproduce-capture-report-a-qa-tester-s-bug-workflow-in-one-macos-app-pfjgp2umm) · Medium · 0 upvotes · 0 comments

---

Tags: [#testing](https://daily.dev/tags/testing), [#java](https://daily.dev/tags/java), [#android](https://daily.dev/tags/android)

[View this post on daily.dev](https://daily.dev/posts/find-more-bugs-using-strictmode-with-firebase-test-lab-for-android-qflurrqz7)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Find More Bugs Using StrictMode with Firebase Test Lab for Android","url":"https://daily.dev/posts/find-more-bugs-using-strictmode-with-firebase-test-lab-for-android-qflurrqz7","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/find-more-bugs-using-strictmode-with-firebase-test-lab-for-android-qflurrqz7"},"datePublished":"2026-08-23T12:18:38.207Z","dateModified":"2026-08-23T12:34:26.959Z","description":"Enabling Android's StrictMode API to catch policy violations like main-thread disk I/O or leaked Activity references, and configuring it to crash the app...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/7ed721de96163685d26ab7e314be3ebc?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/7ed721de96163685d26ab7e314be3ebc?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Firebase","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Firebase","logo":"https://media.daily.dev/image/upload/s--i395oqZH--/f_auto,q_auto/v1787487448/logos/firebase-blog?_a=BAMAMicg0","url":"https://daily.dev/sources/firebase-blog"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/find-more-bugs-using-strictmode-with-firebase-test-lab-for-android-qflurrqz7","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"testing,java,android","timeRequired":"PT5M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Firebase","item":"https://daily.dev/sources/firebase-blog"},{"@type":"ListItem","position":3,"name":"Find More Bugs Using StrictMode with Firebase Test Lab for Android"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/find-more-bugs-using-strictmode-with-firebase-test-lab-for-android-qflurrqz7#faq","mainEntity":[{"@type":"Question","name":"How do I make Android StrictMode crash my app only during Firebase Test Lab runs and not in production?","acceptedAnswer":{"@type":"Answer","text":"Query the device's system settings for the key firebase.test.lab using Settings.System.getString(resolver, \"firebase.test.lab\") and enable fatal StrictMode policies when that value equals \"true\", in addition to when BuildConfig.DEBUG is true. This lets instrumented tests and Robo tests crash and fail visibly on StrictMode violations without affecting real users. See how daily.dev surfaces practical Android testing techniques like StrictMode integration for CI pipelines."}},{"@type":"Question","name":"How do I set up StrictMode to crash the app on any policy violation instead of just logging it?","acceptedAnswer":{"@type":"Answer","text":"Build a StrictMode.ThreadPolicy and StrictMode.VmPolicy with detectAll(), penaltyLog(), and penaltyDeath(), then apply them via StrictMode.setThreadPolicy() and StrictMode.setVmPolicy(). penaltyDeath() forces an immediate crash on violation instead of merely logging it, which is useful for catching bugs like main-thread disk reads during automated testing. Developers hardening Android debug builds can track StrictMode patterns like this through daily.dev."}}]}
```

