Tích hợp Android Frame Pacing (Tốc độ khung hình cho Android) vào trình kết xuất OpenGL
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.
Phần hướng dẫn này mô tả cách tích hợp Android Frame Pacing (Tốc độ khung hình Android) vào chuỗi công cụ, cách sử dụng các hàm mà thư viện cung cấp và cách xác minh tốc độ khung hình đã cải thiện. Android Frame Pacing có sẵn dưới dạng một thư viện tĩnh hoặc thư viện chia sẻ trong Thư viện AGDK.
Chạy mẫu AGDKTunnel trong Android Studio. Dự án
mẫu này tích hợp Android Frame Pacing vào một trò chơi sử dụng OpenGL ES để
kết xuất.
Mở Android Studio
Nhấp vào Projects > Open (Dự án > Mở) rồi chọn thư mục /games-samples/agdk/agdktunnel.
Chờ Android Studio đồng bộ hoá dự án.
Kết nối thiết bị hoặc tạo thiết bị ảo để chạy mẫu (để biết thêm thông tin, hãy xem nội dung Tạo và chạy ứng dụng).
Chọn thiết bị mục tiêu rồi nhấp vào Run (Chạy) .
APK mẫu sẽ tạo bản dựng và cài đặt trên thiết bị mục tiêu. Nếu bạn gặp lỗi, hãy kiểm tra các bước sau:
Bạn có phiên bản được hỗ trợ của SDK Android; xem trường compileSdkVersion trong tệp mô-đun ứng dụng build.gradle để biết thêm thông tin. Bạn có thể cập nhật phiên bản SDK từ thẻ SDK Platforms (Nền tảng SDK) trong SDK Manager (Trình quản lý SDK).
Bạn có một phiên bản được hỗ trợ của Android NDK; xem trường ndkVersion trong tệp mô-đun ứng dụng build.gradle để biết thêm thông tin. Bạn có thể cài đặt một phiên bản cụ thể của NDK từ thẻ SDK Tools (Bộ công cụ SDK) trong Trình quản lý SDK.
Tệp local.properties trong dự án không có mục nhập cho ndk.dir. Vị trí này do Android Studio chỉ định và sử dụng phiên bản NDK ở trên. Nếu bạn đã nhập mục này, hãy xoá toàn bộ dòng.
Sau mỗi lần thay đổi chế độ cài đặt bản dựng, hãy làm sạch dự án (Build > Clean Project (Xây dựng > Làm sạch dự án)) và làm mới các dự án C++ đã liên kết (Build > Refresh Linked C++ Projects (Xây dựng > Làm mới dự án C++ đã liên kết)).
Nội dung và mã mẫu trên trang này phải tuân thủ các giấy phép như mô tả trong phần Giấy phép nội dung. Java và OpenJDK là nhãn hiệu hoặc nhãn hiệu đã đăng ký của Oracle và/hoặc đơn vị liên kết của Oracle.
Cập nhật lần gần đây nhất: 2025-08-26 UTC.
[[["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-08-26 UTC."],[],[],null,["This tutorial describes how to integrate Android Frame Pacing into your\ntoolchain, how to use the functions that the library provides, and how to verify\nthat your frame pacing has improved. Android Frame Pacing is available as a\nstatic or shared library in the AGDK Libraries.\n\nGet started\n\n1. Clone the [`games-samples` repository](https://github.com/android/games-samples.git).\n2. Follow the instructions in the [prerequisites section of the AGDKTunnel README](https://github.com/android/games-samples/tree/main/agdk/agdktunnel#prerequisites).\n3. Run the [AGDKTunnel sample](https://github.com/android/games-samples/tree/main/agdk/agdktunnel) in Android Studio. This example\n project integrates Android Frame Pacing into a game that uses OpenGL ES for\n rendering.\n\n 1. Open Android Studio.\n 2. Click **Projects \\\u003e Open** and select the `/games-samples/agdk/agdktunnel` directory.\n 3. Wait for Android Studio to sync the project.\n 4. Connect a device or create a virtual device to run the sample (for more information, see [Build and run your app](/studio/run)).\n 5. Select the target device and click **Run** .\n 6. The sample APK should build and install on the target device. If you\n encounter errors, check the following:\n\n - You have a [supported version](/games/sdk#requirements) of the Android SDK; see the `compileSdkVersion` field in the app module `build.gradle` file for more information. You can [update the SDK version](/studio/intro/update#sdk-manager) from the **SDK Platforms** tab in the SDK Manager.\n - You have a [supported version](/games/sdk#requirements) of the Android NDK; see the `ndkVersion` field in the app module `build.gradle` file for more information. You can [install a specific version of the NDK](/studio/projects/install-ndk#specific-version) from the **SDK Tools** tab in the SDK Manager.\n - The `local.properties` file in the project does *not* have an entry for `ndk.dir`. This location is specified by Android Studio and uses the NDK version from above. If you have this entry, clear the entire line.\n - After any build setting change, clean the project (**Build \\\u003e Clean\n Project** ) and refresh the linked C++ projects (**Build \\\u003e Refresh\n Linked C++ Projects**)."]]