Kiểm thử ứng dụng bằng tính năng Truyền trực tuyến trên thiết bị Android
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Tính năng Phát trực tuyến trên thiết bị Android cho phép bạn tương tác và kiểm thử ứng dụng trên nhiều cấp độ API và hệ số hình dạng trong các trung tâm dữ liệu bảo mật của Google trong Android Studio. Với tính năng truyền phát nội dung từ thiết bị, bạn có thể tương tác với ứng dụng trên một thiết bị thực, giống như người dùng, bao gồm cả việc xoay và gập thiết bị. Việc này giúp bạn xem cách ứng dụng hoạt động trong nhiều tình huống và xác định mọi vấn đề có thể không xuất hiện trong các môi trường kiểm thử khác.
Làm quen với tính năng truyền phát nội dung từ thiết bị Android
Nếu bạn chưa thực hiện, hãy tải xuống và cài đặt Bản dựng ổn định mới nhất của Android Studio rồi làm theo các bước sau:
Trong Android Studio, hãy mở một dự án Android, chuyển đến cửa sổ công cụ Device Manager (Trình quản lý thiết bị) rồi nhấp vào biểu tượng Firebase.
Nếu bạn chưa đăng nhập vào tài khoản nhà phát triển, hãy nhấp vào Đăng nhập vào Google rồi làm theo lời nhắc.
Sau khi cấp cho Android Studio các quyền được yêu cầu, hãy quay lại IDE và chọn một dự án Firebase. Nếu chưa có dự án Firebase, bạn có thể tạo một dự án miễn phí trong bảng điều khiển Firebase.
Lưu ý: Để bật các quyền thích hợp nhằm sử dụng tính năng phát trực tuyến trên thiết bị với dự án Firebase, hãy xem các quyền Test Lab.
Sau khi chọn một dự án, bạn có thể duyệt xem danh sách thiết bị và chọn những thiết bị mà bạn muốn sử dụng.
Bật quyền cho tính năng Truyền phát nội dung từ thiết bị Android
Để sử dụng tính năng Truyền phát thiết bị, bạn cần sử dụng một dự án Firebase mà bạn có quyền Chỉnh sửa hoặc Sở hữu. Nếu muốn cung cấp các vai trò và quyền cụ thể hơn cho nhóm của mình, bạn có thể bật quyền truy cập vào Phòng thử nghiệm cho tính năng Truyền trực tuyến thiết bị.
Quyền truy cập vào Phòng thử nghiệm
Để định cấu hình quyền truy cập vào Phòng thử nghiệm để có thể thực thi và đọc kết quả kiểm thử, bạn phải định cấu hình quyền truy cập vào bộ chứa Cloud Storage. Bạn có thể cấp quyền truy cập vào Phòng thử nghiệm bằng bảng điều khiển của Firebase hoặc giao diện dòng lệnh gcloud.
Để người dùng chạy thử nghiệm hoặc xem kết quả thử nghiệm từ gcloud CLI trong khi sử dụng vùng lưu trữ Cloud Storage của riêng bạn, bạn có thể chỉ định một cặp vai trò được xác định trước. Cặp vai trò này sẽ cấp cùng nhau bộ quyền cần thiết bằng cách sử dụng bảng điều khiển Google Cloud.
Để chạy kiểm thử, hãy chỉ định vai trò Quản trị viên Phòng thử nghiệm Firebase và Người xem Firebase Analytics.
Để xem kết quả kiểm thử, hãy chỉ định vai trò Người xem Phòng thử nghiệm Firebase và Người xem Firebase Analytics.
Để biết thêm thông tin về cách định cấu hình các quyền chi tiết này của Phòng thử nghiệm, hãy xem hướng dẫn tham khảo về quyền IAM của Phòng thử nghiệm.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-09-06 UTC."],[],[],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)."]]