应用抓取工具
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。

您可以使用应用抓取工具(Jetpack 的一部分)来自动测试您的应用,而无需编写或维护任何代码。
抓取工具与您的应用一起运行,自动发出操作(点按、滑动等)来探索应用的状态空间。如果再也没有要执行的独特操作、应用发生崩溃或达到了您指定的超时,抓取会自动终止。
使用抓取工具进行测试非常简单,因为无需编写或维护任何代码。
此外,您还可以在各种设备上运行该工具,以查找崩溃、视觉问题或性能问题。通常,最好使用基于云的服务(如 Firebase 测试实验室)来更方便快捷地测试屏幕尺寸和硬件配置的多种组合。
目标受众群体
应用抓取工具面向希望以最少的配置来确保应用的基本功能正常的开发者。除了纯黑盒测试之外,还可以将抓取工具配置为提供特定输入,如登录凭据或深层链接。
使用入门
在开始之前,请确保您具有最新版本的 Android SDK,
它随附于 Android Studio。
如果您安装独立的 Android SDK,请确保它包含最新的构建工具和平台工具。
然后,下载抓取工具二进制文件归档。
接下来,启动模拟器或使用 USB 线连接实体设备。
通过运行以下命令来确认设备已连接:
adb devices
如需调用抓取工具,请先将归档提取到您选择的目录中。从该目录中,使用以下命令调用抓取工具:
java -jar crawl_launcher.jar --apk-file path/to/my/app.apk --android-sdk path/to/my/android/sdk
抓取工具选项
您可以使用以下选项来调用抓取工具:
选项 | 说明 |
--android-sdk path
|
指定 Android SDK 的路径。
这是一个必需的标记。
|
--apk-file file
|
指定应用 APK 的路径,应用抓取工具随后会对其进行安装和抓取。
这是一个必需的标记(如果未指定 --app-package-name )。
|
--app-package-name name
|
指定应用的软件包名称。当您的应用已安装在设备上且无需重新安装时,使用此选项。
这是一个必需的标记(如果未指定 --apk-file )。
|
--key-store path
|
指定用于为您的应用和抓取工具 APK 签名的密钥库的路径。当您的应用需要特定签名才能正常运行时,使用此选项。
|
--key-store-password password
|
指定您为 --key-store 选项提供的密钥库的密码。
这是一个必需的标记(如果已指定 --key-store )。
|
--timeout-sec timeout
|
指定抓取的超时(以秒为单位)。如果未指定,抓取会在 60 秒后停止。
|
已知问题
无法删除原始签名文件
在开始抓取之前,JDK 9 用户可能会看到以下错误消息:
androidx.test.tools.crawler.launcher.exceptions.ApkSigningException: Failed to delete original signature files
如果您遇到这种情况,我们建议您使用 JDK 8 或 JDK 10 以及更高版本。如需详细了解此问题,请参阅这一 JDK 9 错误。一些用户通过使用经过更新的 Android Studio 版本重新构建其 APK 解决了此问题。
其他资源
如需详细了解如何使用应用抓取工具,请参阅以下资源。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-27。
[null,null,["最后更新时间 (UTC):2025-07-27。"],[],[],null,["# App Crawler\n\nUse the App Crawler tool, part of [Jetpack](/jetpack), to automatically test\nyour app without the need to write or maintain any code.\n\nThe crawler runs alongside your app, automatically issuing actions\n(tap, swipe, etc.) to explore the state-space of your app.\nThe crawl terminates automatically when there are no more unique actions to\nperform, the app crashes, or a timeout you designate is reached.\n\nTesting with the crawler is easy because there's no code to write or maintain.\nMoreover, you can run it on a variety of devices to look for crashes, visual\nissues, or performance problems. Typically, it's a good idea to use a\ncloud-based service like [Firebase Test\nLab](https://firebase.google.com/docs/test-lab/) to test multiple combinations\nof screen sizes and hardware configurations more easily and quickly.\n\nTarget audience\n---------------\n\nApp Crawler is targeted at developers who want to ensure their app's basic\nfunctionality with minimal configuration. In addition to purely opaque-box\ntesting, the crawler can also be configured to provide specific inputs,\nsuch as login credentials or deep links.\n\nGetting started\n---------------\n\nBefore starting, make sure you have a recent version of the Android SDK.\nThis comes with [Android Studio](/studio).\nIf you install a standalone Android SDK, make sure it includes the latest\nlatest build tools and platform tools.\n\nThen, [download the crawler binary\narchive](https://dl.google.com/appcrawler/beta1/app-crawler.zip).\n\nNext, either start an emulator or connect a physical device using a USB cable.\nConfirm the device is connected by running the following command: \n\n```\nadb devices\n```\n\nTo invoke the crawler, first extract the archive to the directory of your\nchoice. From that directory, invoke the crawler using the following command: \n\n```\njava -jar crawl_launcher.jar --apk-file path/to/my/app.apk --android-sdk path/to/my/android/sdk\n```\n\nCrawler options\n---------------\n\nYou can use the following options to invoke the crawler:\n\n| Option | Description |\n|-----------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `--android-sdk `\u003cvar translate=\"no\"\u003epath\u003c/var\u003e | Specifies the path to your Android SDK. This is a **required** flag. |\n| `--apk-file `\u003cvar translate=\"no\"\u003efile\u003c/var\u003e | Specifies the path to your app APK, which App Crawler then installs and crawls. This is a **required** flag if `--app-package-name` isn't specified. |\n| `--app-package-name `\u003cvar translate=\"no\"\u003ename\u003c/var\u003e | Specifies the package name of your app. Use this option when your app is already installed on the device and no re-installation is required. This is a **required** flag if `--apk-file` isn't specified. |\n| `--key-store `\u003cvar translate=\"no\"\u003epath\u003c/var\u003e | Specifies the path to the keystore that signs your app and crawler APKs. Use this option when your app requires a specific signature to function properly. |\n| `--key-store-password `\u003cvar translate=\"no\"\u003epassword\u003c/var\u003e | Specifies the password for the keystore you provided for `--key-store` option. This is a **required** flag if `--key-store` is specified. |\n| `--timeout-sec `\u003cvar translate=\"no\"\u003etimeout\u003c/var\u003e | Specifies the timeout for your crawl in seconds. If not specified, the crawl stops after 60 seconds. |\n\nKnown issues\n------------\n\n**Failed to delete original signature files**\n\nPrior to the start of the crawl, JDK 9 users may see this error message: \n\n```\nandroidx.test.tools.crawler.launcher.exceptions.ApkSigningException: Failed to delete original signature files\n```\n\nIf you experience this behavior, we recommend using JDK 8 or 10+. For more\ninformation on this issue, see this\n[JDK 9 bug](https://bugs.openjdk.java.net/browse/JDK-8184940).\nSome users have fixed the issue by rebuilding their APK using an updated version\nof Android Studio.\n\nAdditional resources\n--------------------\n\nFor more information about using App Crawler, consult the\nfollowing resources.\n\n- [Firebase Test Lab Robo Test](https://firebase.google.com/docs/test-lab/android/robo-ux-test) contains detailed documentation as well as instructions for how to run crawler tests in the cloud."]]