DeviceTarget class

The device smoke-test target, shipped by oka_android (ADR-0015).

Compiles to a device pipeline: resolve the newest built APK → adb install -r → launch → wait → scan the device log for failure signatures (see deviceFailureSignatures). Steps run through the same composition-time artifact validation as builds — before any tool runs.

Declare it in the composition root (per-project, typed — instead of CLI flags, which the verb/target split replaces):

Oka(
  pipelines: [...],
  targets: [
    DeviceTarget(
      apk: 'build/app/outputs/app-release.apk', // default: newest built
      package: 'dev.example.app',               // default: aapt2 badging
      activity: 'dev.example.app.MainActivity',
      noInstall: true,      // app must already be on the device
      waitSeconds: 15,
      deviceId: 'R5CX...',  // multi-device hosts; `-d` forwards here
    ),
  ],
)

Run with oka run device — oka launch is a CLI alias of the same dispatch (ADR-0015: verbs never know platforms).

Inheritance

Constructors

DeviceTarget({String? apk, String? package, String? activity, bool noInstall = false, int waitSeconds = 10, String? deviceId, String? adbPath, String? aapt2Path, ResolvedToolchain? toolchain})
const

Properties

aapt2Path → String?
final
activity → String?
Launchable-activity override (default: aapt2 dump badging).
final
adbPath → String?
Injectable tool paths (tests / explicit config); null → toolchain.
final
apk → String?
APK to install (default: newest APK under .oka_cache/build/).
final
configOverrides → Map<String, dynamic>
Optional typed config, deep-merged over oka.yaml when this target runs (same precedence as PlatformPipeline.configOverrides). Pure — must not read the filesystem or environment.
no setterinherited
description → String
One-line description, shown when listing discovered targets.
no setteroverride
deviceId → String?
Device serial (adb -s) — required on multi-device hosts (phone + emulator); null lets adb pick (single-device setups only). Settable per-invocation: oka run device -d <id> (or oka launch -d <id>) overrides this via the applyInvocationArgs contract.
final
hashCode → int
The hash code for this object.
no setterinherited
name → String
Lowercase identifier used in oka run <target>. Validated by validateTargetName — must not shadow a reserved core verb.
no setteroverride
noInstall → bool
Skip adb install — the app must already be on the device. A dead process after launch is then not attributed to this run.
final
package → String?
Package name override (default: aapt2 dump badging on the APK).
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
supportedInvocationArgs → Set<String>
Invocation-arg keys this target accepts via oka run <target> --oka-target-arg key=value(and verb shims that forward, e.g.oka launch -d
no setteroverride
toolchain → ResolvedToolchain?
Injectable toolchain (ADR-0013 T2): null → state.resolvedToolchain → default policy. Composition roots building on the shared store seed one ResolvedToolchain here instead of per-step paths.
final
waitSeconds → int
Seconds to wait before the device-log scan.
final

Methods

applyInvocationArgs(Map<String, String> args) → DeviceTarget
Returns a NEW target value with args applied (targets are const values — never mutate; implementations return a copy). Called by the dispatcher before compile only when invocation args are present; the default rejects everything with an actionable error listing the accepted keys, so a target that accepts nothing needs no override.
override
compile(BuildContext ctx) → List<BuildStep>
Compiles this target into an ordered step list.
override
compileTeardown(BuildContext ctx) → List<BuildStep>
Compiles this target's teardown steps (ADR-0018 §2) — same contract as compile, executed by the best-effort runTeardownSteps runner after the forward pipeline ends (success or failure), never masking its result. Steps consume the forward run's PipelineState artifacts (e.g. emulator-serial, the chrome pid/profile-dir sub-handles), so a spawn step and its stop step stay a pure composition pair.
inherited
explainDetails(BuildContext ctx) → List<String>
Generic, platform-agnostic explain hook (ADR-0016 W1): extra pure detail lines oka explain --targets prints for this target, in addition to the compiled step chain (composition render, deploy plan posture, …).
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
Debug string: the target name.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited