---
title: Camera Injection for Android App Testing
description: Feed an image or video into your Android app's camera on a real TestingBot
  device, so you can test QR-code scanning and other camera flows automatically.
source_url:
  html: https://testingbot.com/support/app-automate/help/camera-injection
  md: https://testingbot.com/support/app-automate/help/camera-injection.md
---

# Camera Injection (Android)

Camera injection lets your app see an image or video you provide instead of the device camera's live view. It is built for flows your tests cannot otherwise reach on a device farm — most commonly **scanning a QR code or barcode** , but also document capture, object recognition and any other feature that reads from the camera.

When it is enabled for an app, TestingBot patches your APK so that, during a session, the app's camera frames are replaced by the media you supply. The rest of the app runs normally.

Camera injection is available for **Android** apps on real devices today. It is being rolled out, so if you do not see the option on your account yet, [contact us](https://testingbot.com/support/contact) to have it enabled.

## How it works

TestingBot injects a small instrumentation agent into your uploaded `.apk` and re-signs it with our own signing key. The agent hooks the Android camera APIs (Camera2/CameraX and the legacy Camera API), so apps that use the standard camera stack — including QR libraries built on it — receive your media as camera frames.

The instrumented build is produced once, after upload, and cached. Re-uploading the app or a new agent version rebuilds it automatically.

Because the app is re-signed with a different key, this works the same way as our [app re-signing](https://testingbot.com/support/app-automate/help/app-resigning): see the limitations below.

## Enabling it for an app

There are two ways to turn camera injection on for an uploaded app.

### From the dashboard

On the [live app testing](https://testingbot.com/members/apps/devices/new) page, each Android app in your storage shows a **Camera injection** switch. Turn it on and the instrumented build is prepared in the background, ready for your next session.

### When uploading through the API

Pass `instrument=true` when you [upload the app](https://testingbot.com/support/app-automate/help/upload) to TestingBot storage. The instrumented build is prepared as part of processing.

```bash
curl -u $TB_KEY:$TB_SECRET \
  -X POST "https://api.testingbot.com/v1/storage" \
  -F "file=@/path/to/your-app.apk" \
  -F "instrument=true"
```

The call returns the usual `app_url` (`tb://<appkey>`) you reference from your tests; no other change to your test code is needed.

## Testing a QR-code scan

Upload the QR (or barcode) image you want the app to read, enable camera injection on your app, and start a session. When your app opens its scanner, it reads the injected image exactly as if the device's camera were pointed at it — so the flow that follows a successful scan runs end to end, deterministically, on every run.

Use a plain, high-contrast code with a clear quiet-zone margin, as you would for a real camera. TestingBot presents the code centered in the frame so scanners that crop to a viewfinder still detect it.

## Limitations

- **Android only** for now, on real devices. Emulators have no camera to inject into.
- **Re-signing.** The app is re-signed with TestingBot's key, so any check bound to your original signing identity — [Play Integrity](https://developer.android.com/google/play/integrity) / hardware attestation, or an app that verifies its own signature — may reject the build. Camera injection suits test and debug builds, or apps that do not enforce server-side attestation.
- **Standard camera APIs.** Apps that read frames through Camera2/CameraX or the legacy Camera API are covered. A fully custom native capture path may not be.
- **Obfuscation.** R8/ProGuard-obfuscated release builds are supported.

## Looking for more help?

Have questions or need more information? Reach out via email or Slack.

[Email us](https://testingbot.com/contact/new) [Join our Slack](https://join.slack.com/t/testingb0t/shared_invite/zt-3bcw9xch-jk19~6XPs_xBrsAgAedkCw)
