使用 Android 设备串流功能测试您的应用
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
借助 Android 设备串流功能,您可以通过 Android Studio,在 Google 安全的数据中心内使用不同类型的设备在各种 API 级别与您的应用互动并进行测试。借助设备串流功能,您可以在真实的设备上与您的应用互动,就像用户在现实中操作设备一样,包括旋转和折叠设备。这样,您就可以了解应用在不同情况下的行为,并找出在其他测试环境中可能不明显的那些问题。
Android 设备串流功能使用入门
下载并安装最新的稳定版 Android Studio build(如果您尚未下载该 build),并按以下步骤执行操作:
- 在 Android Studio 中,打开一个 Android 项目,前往设备管理器工具窗口,然后点击 Firebase 图标。
- 如果您尚未登录自己的开发者账号,请点击登录 Google,然后按照提示操作。
- 向 Android Studio 提供所需权限后,返回 IDE 并选择一个 Firebase 项目。如果您还没有 Firebase 项目,可以在 Firebase 控制台中免费创建一个项目。注意:如要了解如何启用所需的权限以便在 Firebase 项目中使用设备串流功能,请参阅 Test Lab 权限。
- 选择项目后,您可以浏览设备列表,并选择您要使用的设备。
- 点击确定。
如需详细了解如何开始使用设备串流功能,请参阅 Android Studio 中的设备串流功能。
为 Android 设备串流功能启用所需权限
若要使用设备串流功能,您需要使用自己具有 Editor 或 Owner 权限的 Firebase 项目。如果您想要为团队提供更具体的角色和权限,则可以为设备串流功能启用 Test Lab 权限。
Test Lab 权限
如需配置 Test Lab 权限,以便能够执行测试并读取测试结果,您必须配置对 Cloud Storage 存储桶的访问权限。您可以使用 Firebase 控制台或 gcloud CLI 为 Test Lab 授予所需的访问权限。
如果想要让用户能够从 Firebase 控制台或 Android Studio 中的 Test Lab 设备矩阵运行测试或查看测试结果,您需要为他们分配项目的 Editor 和 Viewer 角色。
如果想要让用户能够通过 gcloud CLI 运行测试或查看测试结果,同时使用您自己的 Cloud Storage 存储桶,您可以使用 Google Cloud 控制台为他们分配一对预定义角色,以便一并授予一组所需权限。
- 如需运行测试,请分配 Firebase Test Lab Admin 和 Firebase Analytics Viewer 角色。
- 如需查看测试结果,请分配 Firebase Test Lab Viewer 和 Firebase Analytics Viewer 角色。
如需详细了解如何配置这些精细的 Test Lab 权限,请参阅 Test Lab 的 IAM 权限参考指南。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-16。
[null,null,["最后更新时间 (UTC):2025-08-16。"],[],[],null,["\u003cbr /\u003e\n\nAndroid Device Streaming lets you interact with and test your apps across\nmultiple API levels and form factors in Google's secure data centers within\nAndroid Studio. With device streaming, you can interact with your app on a real\ndevice, just like a user would, including rotating and folding the device. This\nlets you see how your app behaves in different situations and to identify\nany problems that might not be apparent in other testing environments.\n\nGet started with Android Device Streaming\n\nIf you haven't done so already, download and install the latest Stable build\nof [Android Studio](https://developer.android.com/studio/) and\nfollow these steps:\n\n1. In Android Studio, open an Android project and navigate to the **Device\n Manager** tool window and click the Firebase icon.\n2. If you're not already signed in to your developer account, click **Log in to\n Google** and follow the prompts.\n3. After providing Android Studio with the requested permissions, return to the IDE and select a Firebase project. If you don't have a Firebase project, you can create one at no cost in the [Firebase console](https://console.firebase.google.com/). Note: To enable the proper permissions to use device streaming with your Firebase project, see [Test Lab permissions](#enable-testlab-permissions).\n4. After selecting a project, you can browse the list of devices and select the devices you want to use.\n5. Click **OK**.\n\nFor more information on how to get started with device streaming, see [Device Streaming in Android Studio](https://developer.android.com/studio/run/android-device-streaming).\n\nEnable permissions for Android Device Streaming\n\nTo use Device Streaming, you need to use a Firebase project that you have either\n**Editor** or **Owner** permissions. If you want to provide more specific roles\nand permissions to your team, you can enable [Test Lab\npermissions](#enable-testlab-permissions) for Device Streaming.\n\nTest Lab permissions\n\nTo configure Test Lab permissions so that you can execute and read your test\nresults, you have to configure access to Cloud Storage buckets. You can grant\naccess to Test Lab, using the Firebase console or gcloud CLI.\n\nFor a user to run tests or view test results from the Firebase console or the\n[Test Lab Device Matrix in Android Studio](https://developer.android.com/studio/test/test-in-android-studio#run-with-firebase-test-lab),\nyou will need to assign them the Editor and Viewer project roles.\n\nFor a user to run tests or view test results from the gcloud CLI while using\nyour own Cloud Storage bucket, you can assign a pair of predefined roles, that\nwill grant the required set of permissions together, using the Google Cloud\nconsole.\n\n- To run test, assign the Firebase Test Lab Admin and Firebase Analytics Viewer roles.\n- To view test results, assign the Firebase Test Lab Viewer and Firebase Analytics Viewer roles.\n\nFor more information on how to configure these granular Test Lab permissions,\nsee Test Lab's [IAM permissions reference guide](/docs/test-lab/android/iam-permissions-reference)."]]