Zintegruj funkcję Android Frame Pacing z mechanizmem renderowania OpenGL
Zadbaj o dobrą organizację dzięki kolekcji
Zapisuj i kategoryzuj treści zgodnie ze swoimi preferencjami.
Z tego samouczka dowiesz się, jak zintegrować z łańcuchem narzędzi funkcję synchronizacji klatek na Androidzie, jak korzystać z funkcji udostępnianych przez bibliotekę i jak sprawdzić, czy synchronizacja klatek została ulepszona. Android Frame Pacing jest dostępny jako statyczna lub udostępniana biblioteka w bibliotekach AGDK.
Rozpocznij
- Sklonuj
games-samples
repozytorium.
- Postępuj zgodnie z instrukcjami w sekcji wymagań wstępnych w pliku README AGDKTunnel.
Uruchom przykładową aplikację AGDKTunnel w Android Studio. Ten przykładowy projekt integruje synchronizację klatek Androida z grą, która do renderowania używa OpenGL ES.
- Otwórz Android Studio.
- Kliknij Projekty > Otwórz i wybierz katalog
/games-samples/agdk/agdktunnel
.
- Poczekaj, aż Android Studio zsynchronizuje projekt.
- Połącz urządzenie lub utwórz urządzenie wirtualne, aby uruchomić przykład (więcej informacji znajdziesz w artykule Tworzenie i uruchamianie aplikacji).
- Wybierz urządzenie docelowe i kliknij Uruchom
.
Przykładowy plik APK powinien zostać skompilowany i zainstalowany na urządzeniu docelowym. Jeśli napotkasz błędy, sprawdź te kwestie:
- Masz obsługiwaną wersję pakietu SDK Androida. Więcej informacji znajdziesz w polu
compileSdkVersion
w pliku build.gradle
modułu aplikacji. Wersję pakietu SDK możesz zaktualizować na karcie Platformy SDK w Menedżerze SDK.
- Musisz mieć obsługiwaną wersję Android NDK. Więcej informacji znajdziesz w polu
ndkVersion
w pliku modułu aplikacjibuild.gradle
. Możesz zainstalować konkretną wersję NDK na karcie Narzędzia SDK w Menedżerze SDK.
- Plik
local.properties
w projekcie nie zawiera wpisu dla ndk.dir
. Ta lokalizacja jest określana przez Android Studio i używa wersji NDK podanej powyżej. Jeśli masz ten wpis, wyczyść cały wiersz.
- Po zmianie ustawień kompilacji wyczyść projekt (Build > Clean Project) i odśwież połączone projekty C++ (Build > Refresh Linked C++ Projects).
Treść strony i umieszczone na niej fragmenty kodu podlegają licencjom opisanym w Licencji na treści. Java i OpenJDK są znakami towarowymi lub zastrzeżonymi znakami towarowymi należącymi do firmy Oracle lub jej podmiotów stowarzyszonych.
Ostatnia aktualizacja: 2025-08-26 UTC.
[null,null,["Ostatnia aktualizacja: 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**)."]]