ADB Install Fails With INSTALL_FAILED_TEST_ONLY
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
INSTALL_FAILED_TEST_ONLY means Android rejected an APK marked as test-only during installation. This usually happens with debug builds or CI artifacts that carry testOnly metadata. The fix is quick for local testing, but you should also make build outputs explicit so test artifacts never leak into release workflows.
Why Android Blocks Test-Only Packages
Android package installer enforces safeguards for packages intended only for testing. When an APK is marked test-only, normal install command without test allowance is rejected.
Typical triggers:
- debug variants with test flags
- instrumentation-oriented build tasks
- custom manifest merge settings
- CI pipelines reusing internal test artifacts
This protection is intentional and helps prevent accidental deployment of non-production packages.
Confirm the APK Metadata
Check whether APK contains test-only flag before changing commands.
If output includes testOnly=true, plain install will fail.
Also check package name and version metadata:
This helps catch accidental wrong artifact selection.
Quick Local Fix: Install with -t
For development devices and emulators, allow test-only install explicitly.
For reinstall over existing package:
Use this for local iteration, QA test beds, and integration test devices.
Correct Fix for Distribution Artifacts
If artifact should install without -t, generate proper non-test build.
Release pipelines should never depend on test-only bypass flags. If they do, artifact promotion policy is broken.
Check Build Variant and Signing Flow
Many teams hit this error because scripts build one variant and attempt to distribute another. Verify build command and output path alignment.
Also verify signing config for release variant in Gradle setup.
Device-Side Cleanup During Troubleshooting
Sometimes stale package state confuses installation attempts. Reset state when needed.
This separates test-only rejection from unrelated package conflicts.
CI Pipeline Hardening Pattern
A robust pipeline should detect test-only metadata and choose install strategy intentionally.
Better still, split jobs by artifact type so debug install and release validation are distinct pipeline stages.
Emulator and Managed Device Notes
For instrumented tests, using test-only packages can be expected. In those paths, keep install commands and Gradle tasks aligned with testing intent.
For managed devices, prefer deterministic setup scripts that include:
- uninstall previous package
- install base app
- install test package if needed
- run tests
This reduces flaky build behavior.
Preventing Test-Only Leakage to Release
Add guardrails in CI:
- fail release job if
testOnly=true - validate signing and variant name
- validate versioning and package id
- publish only approved artifact directories
These checks are lightweight and prevent costly production incidents.
Common Pitfalls
A common pitfall is always using plain adb install while working with debug APKs that require -t. Another is copying debug artifact paths into release scripts and forgetting to update them. Teams also often attempt manual manifest edits to remove test-only behavior, creating fragile build logic. Finally, skipping metadata validation in CI allows wrong APK type to pass through multiple environments before failure appears.
Summary
INSTALL_FAILED_TEST_ONLYindicates installer blocked a test-only package.- Use
adb install -tfor local debug and test workflows. - Generate release artifacts for normal install paths.
- Validate APK metadata and variant type in CI.
- Treat test-only safeguards as protective controls, not obstacles.

