extracting-test-artifacts
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseExtracting Test Artifacts — adb pull / push and run-as
提取测试产物 —— adb pull / push 与 run-as
This skill covers moving files between host and device, the path permission rules that decide whether a succeeds, and the API for routing per-test artefacts. Capture-on-failure orchestration (when to pull what) lives in .
pullandroidx.test:servicesTestStorage../../automation/scripting-adb-for-ci/SKILL.md本 skill 涵盖在主机与设备之间移动文件、决定 是否成功的路径权限规则,以及用于按测试路由产物的 API。失败时捕获的编排(何时拉取哪些内容)位于 。
pullandroidx.test:servicesTestStorage../../automation/scripting-adb-for-ci/SKILL.mdWhen to use this skill
何时使用此 skill
- A test produces artefacts (screenshots, JSON, captured DBs) that need to land on CI as build outputs.
- fails with "Permission denied"; the developer doesn't know
adb pull /data/data/com.example/databases/main.dbexists.run-as - A binary file (PNG, MP4, SQLite DB) arrives on the host with mangled bytes — the missing is the fix.
exec-out - A push of a large APK or test data file is slow; the developer wants the modern compression flags ().
-z brotli - The test app writes screenshots to and the developer wants to know whether that's pullable on API 30+ (it is, when the package owns it).
/sdcard/Android/data/com.example/files/screenshots/ - The team is migrating from "write to /sdcard, pull on the host" to the modern AndroidX API.
TestStorage
- 某个测试生成了需要作为构建输出保存到 CI 上的产物(截图、JSON、捕获的数据库)。
- 出现“Permission denied”,而开发者不知道可以使用
adb pull /data/data/com.example/databases/main.db。run-as - 二进制文件(PNG、MP4、SQLite DB)到达主机后字节被破坏;改用 即可解决。
exec-out - 推送大型 APK 或测试数据文件速度缓慢;开发者希望使用现代压缩标志()。
-z brotli - 测试应用将截图写入 ,开发者想知道在 API 30+ 上是否可以拉取该文件(当包拥有该目录时可以)。
/sdcard/Android/data/com.example/files/screenshots/ - 团队正在从“写入 ,在主机上拉取”的模式迁移到现代 AndroidX
/sdcardAPI。TestStorage
When NOT to use this skill
何时不应使用此 skill
- Capturing the screenshot or video that becomes the artefact. Use .
../../capture/capturing-screenshots-and-screenrecord/SKILL.md - Capturing logs to extract. Use .
../../observability/extracting-logs-with-logcat/SKILL.md - Installing or uninstalling APKs. Use .
../../apps/installing-and-managing-apps/SKILL.md - Driving the device (taps, key events). Use .
../../control/injecting-input-and-state/SKILL.md - The whole CI orchestration (when to pull, retries, parallelisation). Use .
../../automation/scripting-adb-for-ci/SKILL.md
- 捕获作为产物的截图或视频。请使用 。
../../capture/capturing-screenshots-and-screenrecord/SKILL.md - 捕获日志以供提取。请使用 。
../../observability/extracting-logs-with-logcat/SKILL.md - 安装或卸载 APK。请使用 。
../../apps/installing-and-managing-apps/SKILL.md - 驱动设备(点击、按键事件)。请使用 。
../../control/injecting-input-and-state/SKILL.md - 完整的 CI 编排(何时拉取、重试、并行化)。请使用 。
../../automation/scripting-adb-for-ci/SKILL.md
Prerequisites
前置条件
- returns
adb get-state. Seedevice.../../devices/connecting-to-devices/SKILL.md - For : the target APK must be
run-asin its merged manifest (the defaultandroid:debuggable="true"build variant).debug - For /
-z brotli: platform-tools 30+ on the host and adbd ≥ Android 11 on the device.zstd - For :
TestStorageand theandroidx.test:servicesargument to-e useTestStorageService true.am instrument
- 返回
adb get-state。请参阅device。../../devices/connecting-to-devices/SKILL.md - 对于 :目标 APK 的合并清单中必须包含
run-as(默认的android:debuggable="true"构建变体满足此条件)。debug - 对于 /
-z brotli:主机上的 platform-tools 需为 30+,设备上的 adbd 需为 Android 11 或更高版本。zstd - 对于 :需要
TestStorage,并向androidx.test:services传入am instrument参数。-e useTestStorageService true
Symmetric syntax
对称语法
"Unlike thecommand, which only copies an APK file to a specific location, theinstallandpullcommands let you copy arbitrary directories and files to any location in a device." — developer.android.com/tools/adbpush
adb pull <remote> [<local>] # device → host (defaults to cwd)
adb push <local> <remote> # host → device“与只能将 APK 文件复制到特定位置的命令不同,install和pull命令允许将任意目录和文件复制到设备中的任意位置。”——developer.android.com/tools/adbpush
adb pull <remote> [<local>] # device → host (defaults to cwd)
adb push <local> <remote> # host → deviceModern flags (platform-tools ≥ 30)
现代标志(platform-tools ≥ 30)
push [--sync] [-z ALGORITHM] [-Z] LOCAL... REMOTE
pull [-a] [-z ALGORITHM] [-Z] REMOTE... LOCAL| Flag | Meaning |
|---|---|
| Enable compression. |
| Disable compression. |
| Only push files with different timestamps — fast incremental updates. |
| Preserve file timestamp and mode. |
| Dry-run. |
| Suppress progress messages. |
The legacy (show progress) is now a no-op — modern adb shows progress by default and silences it. Don't rely on in CI scripts.
adb pull -p-q-ppush [--sync] [-z ALGORITHM] [-Z] LOCAL... REMOTE
pull [-a] [-z ALGORITHM] [-Z] REMOTE... LOCAL| 标志 | 含义 |
|---|---|
| 启用压缩。 |
| 禁用压缩。 |
| 仅推送时间戳不同的文件,用于快速增量更新。 |
| 保留文件时间戳和权限模式。 |
| 空运行。 |
| 禁止显示进度消息。 |
旧版的 (显示进度)现在已不起作用——现代 adb 默认显示进度,可使用 静默。不要在 CI 脚本中依赖 。
adb pull -p-q-pPath permission rules
路径权限规则
This is the load-bearing table. Most "permission denied" failures come from misunderstanding it.
adb pull| Path | adb shell writable? | |
|---|---|---|
| Yes | Yes |
| Yes (scoped storage rules on API 30+) | Yes |
| Only via | Only via |
| Package-owned, scoped storage | Yes for the owning package, and yes for |
这是最关键的表格。大多数“Permission denied”类型的 失败都源于对此规则的误解。
adb pull| 路径 | adb shell 可写? | |
|---|---|---|
| 是 | 是 |
| 是(API 30+ 上遵循 scoped storage 规则) | 是 |
| 仅可通过 | 仅可通过 |
| 归包所有,受 scoped storage 约束 | 所属包可以使用, |
/data/local/tmp/
/data/local/tmp//data/local/tmp/
/data/local/tmp/Readable/writable by the user that backs . No app-permission ceremony required. Use as the staging directory for everything: pushed APKs, test data, captured screenshots, JSON inputs, dexed instrumentation jars.
shelladbCaveat: your app runs as , not , so the app cannot read shell-written files unless you and the parent is world-readable. itself is , so be deliberate when pushing files the app must read.
u0_aXXshellchmod 0644/data/local/tmp/0771可由 adb 背后的 用户读取和写入,无需申请应用权限。应将其作为所有内容的暂存目录:推送的 APK、测试数据、捕获的截图、JSON 输入以及经 dex 处理的 instrumentation jar。
shell注意:应用以 而不是 身份运行,因此除非执行 并确保父目录可被全局读取,否则应用无法读取 shell 写入的文件。 本身的权限为 ,因此在推送应用必须读取的文件时应谨慎配置权限。
u0_aXXshellchmod 0644/data/local/tmp/0771/sdcard/
/sdcard//sdcard/
/sdcard/Alias , sometimes . Public/external storage. ADB's user retains FUSE/sdcardfs access on API 30+, so and work for tests even after scoped storage tightening. App-side writes are gated through MediaStore on API 30+.
/storage/emulated/0//storage/self/primary/shelladb push /sdcard/...adb pull /sdcard/...它是 的别名,有时也称为 。这是公共存储或外部存储。即使 scoped storage 已收紧,ADB 的 用户在 API 30+ 上仍可通过 FUSE/sdcardfs 访问,因此即使在 scoped storage 限制生效后, 和 仍可用于测试。在 API 30+ 上,应用侧的写入受 MediaStore 限制。
/storage/emulated/0//storage/self/primary/shelladb push /sdcard/...adb pull /sdcard/.../data/data/<pkg>/
— run-as
only
/data/data/<pkg>/run-as/data/data/<pkg>/
—— 只能使用 run-as
/data/data/<pkg>/run-asOwned by the app's UID; on the dir itself. A bare fails on production user builds. Two viable paths:
0700adb pull /data/data/com.example/...- on debuggable builds (most common).
run-as <pkg> - on
adb root/userdebugbuilds (covered briefly ineng).../../automation/scripting-adb-for-ci/SKILL.md
该目录归应用 UID 所有,目录本身的权限为 。直接执行 会在生产环境用户构建中失败。可采用以下两种方式:
0700adb pull /data/data/com.example/...- 在可调试构建上使用 (最常见)。
run-as <pkg> - 在 /
userdebug构建上使用eng(详见adb root)。../../automation/scripting-adb-for-ci/SKILL.md
/sdcard/Android/data/<pkg>/files/
/sdcard/Android/data/<pkg>/files//sdcard/Android/data/<pkg>/files/
/sdcard/Android/data/<pkg>/files/The app's "external private" storage — written from the app via . Readable from because it lives under FUSE-emulated SD card. The path of least resistance for "write artefact, pull from CI" on Android 11+:
Context.getExternalFilesDir(null)adb shellbash
undefined这是应用的“外部私有”存储,可通过 从应用写入。由于它位于 FUSE 模拟的 SD 卡下,因此可由 读取。对于 Android 11+ 上“写入产物,再从 CI 拉取”的需求,这是阻力最小的路径:
Context.getExternalFilesDir(null)adb shellbash
undefinedInside the test app:
Inside the test app:
val out = File(context.getExternalFilesDir(null), "screenshots/fail.png")
```bashval out = File(context.getExternalFilesDir(null), "screenshots/fail.png")
```bashFrom CI:
From CI:
adb pull /sdcard/Android/data/com.example/files/screenshots/fail.png ./
undefinedadb pull /sdcard/Android/data/com.example/files/screenshots/fail.png ./
undefinedrun-as
on debuggable builds
run-as在可调试构建上使用 run-as
run-asrun-as <pkg>android:debuggable="true"debugadb shell run-as <pkg> <cmd>run-as <pkg>android:debuggable="true"debugadb shell run-as <pkg> <cmd>Text-file grab
获取文本文件
bash
adb shell run-as com.example.app cat databases/main.db > main.dbThis works for short text files. For binary files it can corrupt bytes via PTY translation (see below).
exec-outbash
adb shell run-as com.example.app cat databases/main.db > main.db该方式适用于短文本文件。对于二进制文件,PTY 转换可能会破坏字节(请参阅下文的 )。
exec-outBinary-clean grab via exec-out
+ tar
exec-outtar通过 exec-out
+ tar
实现二进制无损获取
exec-outtarFor directories, binary files, or anything with in the bytes, MUST use (binary-clean stdout) and pipe through :
\nexec-outtarbash
adb exec-out run-as com.example.app tar cf - databases/ \
| tar xf - -C ./pulledThe produces an archive on stdout; the local extracts it into . No intermediate file, no PTY translation, works for arbitrary binary content.
tar cf -tar xf -./pulled/对于目录、二进制文件或任何内容字节中包含 的文件,必须使用 (无损二进制标准输出)并通过 管道传输:
\nexec-outtarbash
adb exec-out run-as com.example.app tar cf - databases/ \
| tar xf - -C ./pulledtar cf -tar xf -./pulled/Single-file binary grab
获取单个二进制文件
bash
adb exec-out run-as com.example.app cat databases/main.db > main.dbexec-outbash
adb exec-out run-as com.example.app cat databases/main.db > main.dbexec-outListing
列出文件
bash
adb shell run-as com.example.app ls -lR files/bash
adb shell run-as com.example.app ls -lR files/Three things run-as
cannot do
run-asrun-as
无法完成的三件事
run-as- Work on release / non-debuggable builds. Will print "Package is not debuggable".
- Switch to a system UID (only the target package's UID).
- Cross profile boundaries by itself. Use if needed.
--user N
- 无法在 release 或不可调试构建上运行。此时会输出“Package is not debuggable”。
- 无法切换到 system UID,只能使用目标包的 UID。
- 无法自行跨越 profile 边界;如有需要,请使用 。
--user N
Common test-artefact paths
常见测试产物路径
| Path | Origin |
|---|---|
| Gradle's standard "additional output" sink. The instrumentation runner pulls anything declared via |
| JUnit-style XML test results — ingested directly by Jenkins/GHA/etc. |
| HTML test report. |
(See developer.android.com/studio/test/command-line: HTML at , XML at .)
module/build/reports/androidTests/connected/module/build/outputs/androidTest-results/connected/| 路径 | 来源 |
|---|---|
| Gradle 标准的“additional output”接收目录。instrumentation runner 会拉取通过 |
| JUnit 风格的 XML 测试结果,可由 Jenkins/GHA 等系统直接读取。 |
| HTML 测试报告。 |
(请参阅 developer.android.com/studio/test/command-line:HTML 位于 ,XML 位于 。)
module/build/reports/androidTests/connected/module/build/outputs/androidTest-results/connected/Modern artefact API — TestStorage
TestStorage现代产物 API —— TestStorage
TestStorageThe legacy pattern is "write to , pull from CI script". The modern pattern routes through and a flag.
/sdcard/...androidx.test.services.storage.TestStorageuseTestStorageService旧模式是“写入 ,再通过 CI 脚本拉取”。现代模式通过 和 标志进行路由。
/sdcard/...androidx.test.services.storage.TestStorageuseTestStorageServiceWiring
配置
kotlin
// dependencies
androidTestImplementation("androidx.test:runner:1.7.0")
androidTestUtil("androidx.test.services:test-services:1.6.0")kotlin
// am instrument args (or Gradle: testInstrumentationRunnerArguments)
adb shell am instrument -w -r \
-e useTestStorageService true \
com.example.test/androidx.test.runner.AndroidJUnitRunnerkotlin
// dependencies
androidTestImplementation("androidx.test:runner:1.7.0")
androidTestUtil("androidx.test.services:test-services:1.6.0")kotlin
// am instrument args (or Gradle: testInstrumentationRunnerArguments)
adb shell am instrument -w -r \
-e useTestStorageService true \
com.example.test/androidx.test.runner.AndroidJUnitRunnerIn-test usage
在测试中使用
kotlin
val storage = androidx.test.platform.io.PlatformTestStorageRegistry.getInstance()
storage.openOutputFile("screenshots/fail-${test.methodName}.png").use { out ->
out.write(pngBytes)
}kotlin
val storage = androidx.test.platform.io.PlatformTestStorageRegistry.getInstance()
storage.openOutputFile("screenshots/fail-${test.methodName}.png").use { out ->
out.write(pngBytes)
}What TestStorage
solves
TestStorageTestStorage
解决的问题
TestStorage- Output files land in a TestStorageService-managed directory rather than proper.
/sdcard/ - Gradle's automatically pulls them into
connectedAndroidTest.app/build/outputs/connected_android_test_additional_output/ - Per-test artefact namespacing happens through the runner, not via hand-rolled filename mangling.
Class.method - Compatible with Test Orchestrator's — the storage service holds artefacts even though the test app is wiped between tests.
clearPackageData: 'true'
For non-Gradle pipelines, the storage backs onto the same FS layout, addressable as for legacy compatibility.
/sdcard/googletest/test_outputfiles/...- 输出文件会进入 TestStorageService 管理的目录,而不是直接位于 下。
/sdcard/ - Gradle 的 会自动将它们拉取到
connectedAndroidTest。app/build/outputs/connected_android_test_additional_output/ - 按测试划分产物命名空间由 runner 处理,无需自行拼接 文件名。
Class.method - 兼容 Test Orchestrator 的 ;即使测试应用在测试之间被清除,storage service 仍会保留产物。
clearPackageData: 'true'
对于非 Gradle 流水线,storage 会使用相同的文件系统布局,并且仍可通过 访问,以保持向后兼容。
/sdcard/googletest/test_outputfiles/...Patterns
模式
Pattern: WRONG — adb pull /data/data/<pkg>/...
on a debuggable build
adb pull /data/data/<pkg>/...模式:错误 —— 在可调试构建上执行 adb pull /data/data/<pkg>/...
adb pull /data/data/<pkg>/...bash
undefinedbash
undefinedWRONG
WRONG
adb pull /data/data/com.example/databases/main.db
adb pull /data/data/com.example/databases/main.db
adb: error: failed to stat remote object '/data/data/com.example/databases/main.db': Permission denied
adb: error: failed to stat remote object '/data/data/com.example/databases/main.db': Permission denied
WRONG because: /data/data/<pkg>/ is owned by the app UID with mode 0700. The shell user
WRONG because: /data/data/<pkg>/ is owned by the app UID with mode 0700. The shell user
cannot traverse it. run-as solves this on debuggable builds.
cannot traverse it. run-as solves this on debuggable builds.
```bash
```bashRIGHT — run-as + exec-out + cat for a binary-clean grab
RIGHT — run-as + exec-out + cat for a binary-clean grab
adb exec-out run-as com.example cat databases/main.db > main.db
file main.db # → "SQLite 3.x database"
Or for a directory:
```bash
adb exec-out run-as com.example tar cf - databases/ | tar xf - -C ./pulledadb exec-out run-as com.example cat databases/main.db > main.db
file main.db # → "SQLite 3.x database"
或者处理目录:
```bash
adb exec-out run-as com.example tar cf - databases/ | tar xf - -C ./pulledPattern: WRONG — adb shell run-as <pkg> cat <binary>
for binary files
adb shell run-as <pkg> cat <binary>模式:错误 —— 对二进制文件使用 adb shell run-as <pkg> cat <binary>
adb shell run-as <pkg> cat <binary>bash
undefinedbash
undefinedWRONG (on Windows / certain CI hosts)
WRONG (on Windows / certain CI hosts)
adb shell run-as com.example cat databases/main.db > main.db
adb shell run-as com.example cat databases/main.db > main.db
WRONG because: adb shell
allocates a PTY and translates LF to CRLF on stdout. SQLite
adb shellWRONG because: adb shell
allocates a PTY and translates LF to CRLF on stdout. SQLite
adb shellheaders and other binary content get corrupted. The pulled DB fails to open.
headers and other binary content get corrupted. The pulled DB fails to open.
```bash
```bashRIGHT — exec-out is binary-clean
RIGHT — exec-out is binary-clean
adb exec-out run-as com.example cat databases/main.db > main.db
undefinedadb exec-out run-as com.example cat databases/main.db > main.db
undefinedPattern: writing artefacts in-app, pulling from CI
模式:在应用内写入产物,并从 CI 拉取
kotlin
// In production / test code
val out = File(context.getExternalFilesDir(null), "captures/${name}.png")
out.outputStream().use { it.write(bitmapBytes) }bash
undefinedkotlin
// In production / test code
val out = File(context.getExternalFilesDir(null), "captures/${name}.png")
out.outputStream().use { it.write(bitmapBytes) }bash
undefinedCI script
CI script
adb pull /sdcard/Android/data/com.example/files/captures/ ./artifacts/
This works on API 30+ without `run-as` because `/sdcard/Android/data/<pkg>/files/` is the package's own external-private dir. Both the app and `adb shell` (FUSE bridge) can read it.adb pull /sdcard/Android/data/com.example/files/captures/ ./artifacts/
该方式在 API 30+ 上无需 `run-as` 即可工作,因为 `/sdcard/Android/data/<pkg>/files/` 是包自己的外部私有目录。应用和 `adb shell`(通过 FUSE bridge)都可以读取该目录。Pattern: fast incremental push of large test data
模式:快速增量推送大型测试数据
bash
adb push --sync -z brotli ./fixtures/ /sdcard/fixtures/--sync-z brotlibash
adb push --sync -z brotli ./fixtures/ /sdcard/fixtures/--sync-z brotliPattern: capture-on-failure with TestStorage
TestStorage模式:使用 TestStorage
实现失败时捕获
TestStoragekotlin
class CaptureOnFailureRule : TestWatcher() {
override fun failed(e: Throwable, description: Description) {
val storage = PlatformTestStorageRegistry.getInstance()
val name = "${description.className}.${description.methodName}"
storage.openOutputFile("captures/$name.png").use { out ->
out.write(captureScreenshotPng())
}
}
}After , the artefact lands in automatically.
connectedAndroidTestapp/build/outputs/connected_android_test_additional_output/<flavor><Variant>/connected/<device>/captures/<name>.pngkotlin
class CaptureOnFailureRule : TestWatcher() {
override fun failed(e: Throwable, description: Description) {
val storage = PlatformTestStorageRegistry.getInstance()
val name = "${description.className}.${description.methodName}"
storage.openOutputFile("captures/$name.png").use { out ->
out.write(captureScreenshotPng())
}
}
}执行 后,产物会自动出现在 。
connectedAndroidTestapp/build/outputs/connected_android_test_additional_output/<flavor><Variant>/connected/<device>/captures/<name>.pngMandatory rules
强制规则
- MUST use (not
adb exec-out run-as <pkg> cat <path>) for binary file grabs. PTY translation corrupts binary on Windows and some CI hosts.adb shell run-as ... - MUST use for directory grabs from
adb exec-out run-as <pkg> tar cf - <dir> | tar xf -. There is no/data/data/<pkg>/equivalent that works throughadb pull.run-as - MUST verify the build is debuggable before scripting . On a release APK,
run-asexits non-zero with "Package is not debuggable".run-as - MUST prefer (via
/sdcard/Android/data/<pkg>/files/) over arbitraryContext.getExternalFilesDir(null)for app-written test artefacts on API 30+. The latter is gated by MediaStore for app writes./sdcard/<dir>/ - MUST prefer (
TestStorage+-e useTestStorageService true) over hand-rolledandroidx.test:servicespaths for new test infrastructure. It namespaces per-test artefacts and integrates with Gradle's/sdcard/...sink.connected_android_test_additional_output/ - MUST NOT rely on (show progress) — it is a legacy no-op on platform-tools 30+. Use the default progress meter (or
adb pull -pto silence).-q - MUST NOT assume of
adb pullworks without/data/data/<pkg>/.... It does not, even on debuggable builds —run-asis apull-user operation.shell - PREFERRED: for repeated pushes of large fixture sets. Brotli + timestamp-skip is dramatically faster on slow USB 2.0 cables.
--sync -z brotli - PREFERRED: Test Orchestrator + +
clearPackageData: 'true'for hermetic test isolation with retained artefacts.useTestStorageService: 'true'
- 对于二进制文件获取,必须使用 ,而不是
adb exec-out run-as <pkg> cat <path>。在 Windows 和部分 CI 主机上,PTY 转换会破坏二进制数据。adb shell run-as ... - 从 获取目录时,必须使用
/data/data/<pkg>/。不存在可通过adb exec-out run-as <pkg> tar cf - <dir> | tar xf -使用的等效run-as命令。adb pull - 在脚本中使用 前,必须验证构建是否可调试。在 release APK 上,
run-as会以非零状态退出,并输出“Package is not debuggable”。run-as - 在 API 30+ 上,为应用写入的测试产物时,必须优先使用 (通过
/sdcard/Android/data/<pkg>/files/),而不是任意Context.getExternalFilesDir(null)路径。后者的应用写入受 MediaStore 限制。/sdcard/<dir>/ - 对于新的测试基础设施,必须优先使用 (
TestStorage+-e useTestStorageService true),而不是自行拼接androidx.test:services路径。它能够按测试划分产物命名空间,并与 Gradle 的/sdcard/...接收目录集成。connected_android_test_additional_output/ - 不得依赖 (显示进度);在 platform-tools 30+ 上它已是旧版空操作。请使用默认进度条,或使用
adb pull -p禁止输出。-q - 不得假设无需 即可对
run-as执行/data/data/<pkg>/...。即使在可调试构建上也无法执行,因为adb pull是以pull用户身份进行的操作。shell - 推荐:重复推送大型 fixture 集合时使用 。在较慢的 USB 2.0 线缆上,Brotli 加时间戳跳过可显著提升速度。
--sync -z brotli - 推荐:使用 Test Orchestrator + +
clearPackageData: 'true',实现保留产物的密封式测试隔离。useTestStorageService: 'true'
Verification
验证
- No script invokes directly. All such pulls go through
adb pull /data/data/<pkg>/....run-as - Binary-file pulls use , not
adb exec-out.adb shell - All app-written test artefacts target (lands at
Context.getExternalFilesDir(...)), not/sdcard/Android/data/<pkg>/files/./sdcard/<arbitrary>/ - CI archives for the modern artefact API.
app/build/outputs/connected_android_test_additional_output/**/* - Repeated pushes of the same fixture dir use so unchanged files are skipped.
adb push --sync - reports the correct binary type for every pulled artefact (no CRLF corruption).
file - Release APKs have no test code paths that try to from
adb pull— those would fail./data/data/<pkg>/...
- 没有脚本直接调用 。所有此类拉取操作都通过
adb pull /data/data/<pkg>/...完成。run-as - 二进制文件拉取使用 ,而不是
adb exec-out。adb shell - 所有由应用写入的测试产物都指向 (位于
Context.getExternalFilesDir(...)),而不是/sdcard/Android/data/<pkg>/files/。/sdcard/<任意目录>/ - CI 会归档 ,以收集现代产物 API 生成的文件。
app/build/outputs/connected_android_test_additional_output/**/* - 重复推送同一 fixture 目录时使用 ,从而跳过未变更的文件。
adb push --sync - 为每个拉取的产物报告正确的二进制类型,不存在 CRLF 损坏。
file - Release APK 中不存在尝试从 执行
/data/data/<pkg>/...的测试代码路径,因为这些操作会失败。adb pull
References
参考资料
- developer.android.com/tools/adb — /
pullsyntax, "let you copy arbitrary directories and files to any location in a device" quote.push - developer.android.com/studio/test/command-line — Gradle output dir conventions: HTML at , XML at
module/build/reports/androidTests/connected/.module/build/outputs/androidTest-results/connected/ - developer.android.com/training/data-storage/app-specific — and the API-30+ scoped-storage rules.
Context.getExternalFilesDir() - developer.android.com/reference/androidx/test/services/storage/TestStorage — the modern artefact API.
- developer.android.com/reference/androidx/test/platform/io/PlatformTestStorageRegistry — host-side handle.
- Research note — full pull/push surface, path permission rules, run-as patterns, scoped storage on Android 11+, TestStorage wiring.
tasks/research/A3-adb-observability-automation.md - Sibling skill: — server / daemon, exec-out vs shell.
../../architecture/understanding-adb-architecture/SKILL.md - Sibling skill: —
../../devices/connecting-to-devices/SKILL.md, multi-device targeting.adb get-state - Sibling skill: — wireless transport.
../../devices/connecting-over-wifi/SKILL.md - Sibling skill: —
../../apps/installing-and-managing-apps/SKILL.mdand the debuggable-build flag.pm install - Sibling skill: —
../../tests/running-instrumented-tests-via-adb/SKILL.mdarguments includingam instrument.useTestStorageService - Sibling skill: — driving the scenario that produces the artefact.
../../control/injecting-input-and-state/SKILL.md - Sibling skill: — producing PNG / MP4 to pull.
../../capture/capturing-screenshots-and-screenrecord/SKILL.md - Sibling skill: — pulling rotated log files via
../../observability/extracting-logs-with-logcat/SKILL.md+adb shell logcat -f.adb pull - Sibling skill: — full CI orchestration.
../../automation/scripting-adb-for-ci/SKILL.md - Cross-set: —
../../../instrumentation/runner/running-instrumented-tests-with-androidjunit4/SKILL.mdrules wired toTestWatcher.TestStorage - Cross-set: — Activity-driven scenarios that emit artefacts.
../../../instrumentation/scenarios/launching-activities-with-activityscenario/SKILL.md - Cross-set: — when artefacts are the right observability layer.
../../../fundamentals/strategies/applying-testing-strategies/SKILL.md
- developer.android.com/tools/adb —— /
pull语法,以及“允许将任意目录和文件复制到设备中的任意位置”这句话。push - developer.android.com/studio/test/command-line —— Gradle 输出目录约定:HTML 位于 ,XML 位于
module/build/reports/androidTests/connected/。module/build/outputs/androidTest-results/connected/ - developer.android.com/training/data-storage/app-specific —— 和 API 30+ scoped storage 规则。
Context.getExternalFilesDir() - developer.android.com/reference/androidx/test/services/storage/TestStorage —— 现代产物 API。
- developer.android.com/reference/androidx/test/platform/io/PlatformTestStorageRegistry —— 宿主端句柄。
- 研究说明 —— 完整的 pull/push 功能范围、路径权限规则、run-as 模式、Android 11+ scoped storage 和 TestStorage 配置。
tasks/research/A3-adb-observability-automation.md - 同级 skill:—— server/daemon、exec-out 与 shell 的区别。
../../architecture/understanding-adb-architecture/SKILL.md - 同级 skill:——
../../devices/connecting-to-devices/SKILL.md和多设备定向。adb get-state - 同级 skill:—— 无线传输。
../../devices/connecting-over-wifi/SKILL.md - 同级 skill:——
../../apps/installing-and-managing-apps/SKILL.md和可调试构建标志。pm install - 同级 skill:——
../../tests/running-instrumented-tests-via-adb/SKILL.md参数,包括am instrument。useTestStorageService - 同级 skill:—— 驱动生成产物的测试场景。
../../control/injecting-input-and-state/SKILL.md - 同级 skill:—— 生成可供拉取的 PNG/MP4。
../../capture/capturing-screenshots-and-screenrecord/SKILL.md - 同级 skill:—— 通过
../../observability/extracting-logs-with-logcat/SKILL.md+adb shell logcat -f拉取轮转日志文件。adb pull - 同级 skill:—— 完整的 CI 编排。
../../automation/scripting-adb-for-ci/SKILL.md - 跨集合:—— 接入
../../../instrumentation/runner/running-instrumented-tests-with-androidjunit4/SKILL.md的TestStorage规则。TestWatcher - 跨集合:—— 生成产物的 Activity 驱动场景。
../../../instrumentation/scenarios/launching-activities-with-activityscenario/SKILL.md - 跨集合:—— 确定何时应使用产物作为可观测性层。
../../../fundamentals/strategies/applying-testing-strategies/SKILL.md