If you're using CMake, see the gamesdk/samples/bouncyball/app/CMakeLists.txt
file in the downloaded SDK for an example CMake configuration. It includes a
utility file called gamesdk/samples/gamesdk.cmake, which performs final
checks, adds the proper compiler include paths, and generates a target that you
can use to link the library.
To use the gamesdk.cmake utility:
Include this file in your CMakeLists.txt:
// Use a relative or absolute path. For example, /home/yourusername/gamesdk
// or C:\Android\gamesdk.
include("path/to/gamesdk/samples/gamesdk.cmake")
针对包含 gamesdk 的文件夹调用 add_gamesdk_target 函数:
// Use a relative or absolute path.
add_gamesdk_target(PACKAGE_DIR path/to/gamesdk)
在原生库的 target_link_libraries 中,添加 oboe 作为依赖项:
// The casing of OpenSLES is important.
target_link_libraries(native-lib oboe OpenSLES ...)
[null,null,["最后更新时间 (UTC):2025-08-01。"],[],[],null,["# Update your build settings for Oboe\n\nThere are two ways to incorporate the Oboe library into your project.\n\n- [Integrate Oboe with Gradle and CMake](#integrate-native)\n\n- [Download the Android Game SDK and integrate Oboe manually](#integrate-download)\n\nIntegrate Oboe with Gradle and CMake\n------------------------------------\n\nThese instructions are for projects using [Android Gradle plugin version 4.1.0 or higher](/studio/releases/gradle-plugin)\nusing [native dependencies](/studio/build/dependencies#using-native-dependencies?buildsystem=cmake)\nwith CMake.\n\nIf your project is using either the Android Gradle plugin version 4.0 or\n`ndk-build` instead of CMake, the process is slightly different. See [Using native dependencies](/studio/build/dependencies#using-native-dependencies?buildsystem=ndk-build&agpversion=4.0).\n| **Note:** Native dependencies have minimum version requirements for Gradle and the Android Gradle plugin. If you have an existing project, you may need to update the project Gradle version to 6.5.0 or later and the Android Gradle plugin version to 4.1.0 or later. For more information on updating these versions, see [Android Gradle plugin release notes](/studio/releases/gradle-plugin).\n\n### Update build.gradle\n\nTo add Oboe to your app while using Android Gradle plugin version 4.1.0 or\nhigher, make the following additions to your app's `build.gradle` file.\n\n1. Add the `oboe` dependency to the `dependencies` section. If necessary,\n replace `1.5.0` with the [latest stable version](https://github.com/google/oboe/releases/)\n of Oboe:\n\n dependencies {\n implementation 'com.google.oboe:oboe:1.5.0'\n }\n\n2. Enable the `prefab` option in the `buildFeatures` section.\n\n android {\n buildFeatures {\n prefab true\n }\n }\n\n3. Configure your app to use the shared STL:\n\n android {\n defaultConfig {\n externalNativeBuild {\n cmake {\n arguments \"-DANDROID_STL=c++_shared\"\n }\n }\n }\n }\n\n### Update CMakeLists.txt\n\nAdding Oboe requires two additions to your app's `CMakeLists.txt` file.\n\n1. Add the following `find_package` command:\n\n find_package (oboe REQUIRED CONFIG)\n\n2. Add `oboe::oboe` to the list of libraries passed to the\n `target_link_libraries` command associated with your main executable.\n\nIntegrate with the Android Game SDK\n-----------------------------------\n\n1. [Download the library](https://developer.android.com/games/sdk) and check\n it into your source control system.\n\n2. Make the following changes to your project's build settings.\n\n| **Note:** To use Oboe, you must specify a minimum API level of 16 and NDK release of 18 for the Android Game SDK libraries. If you don't, Oboe can't be found at build time.\n\n### Static library\n\nWhen you integrate with the Android Game SDK, you statically link to a version\nof the Oboe library compiled for the given ABI, API level, NDK, and STL\ncombination:\n\n1. Add `gamesdk/include` to your compiler include paths.\n2. Add a path of the following form in your linker library paths:\n\n ```\n gamesdk/libs/architecture_APIapiLevel_NDKndkVersion_stlVersion_Release\n ```\n\n For example: `gamesdk/libs/arm64-v8a_API24_NDK18_cpp_static_Release`\n3. Add `-loboe_static` to your linker command.\n\nYou don't need to bundle the `liboboe.so` shared library, which means static\nlinking gives you a much smaller code footprint.\n\n### Shared library\n\nIf the ABI, API level, NDK, and STL combination required for a static library\nisn't available for your settings, you can link against the shared library\ninstead:\n\n1. Follow steps 1 and 2 from the previous section (about the static library) to\n update your compiler include paths, and use the appropriate header file.\n\n2. Add a path of the following form in your linker library paths:\n\n \u003cbr /\u003e\n\n ```\n gamesdk/libs/architectureAPI\u003cvar translate=\"no\"\u003eapiLevel\u003c/var\u003eNDKndkVersion_stlVersion_Release/lib/oboe\n ```\n3. Add `-loboe -lOpenSLES` to your linker command.\n\n### Using CMake (static library only)\n\nIf you're using CMake, see the `gamesdk/samples/bouncyball/app/CMakeLists.txt`\nfile in the downloaded SDK for an example CMake configuration. It includes a\nutility file called `gamesdk/samples/gamesdk.cmake`, which performs final\nchecks, adds the proper compiler include paths, and generates a target that you\ncan use to link the library.\n\nTo use the `gamesdk.cmake` utility:\n\n1. Include this file in your `CMakeLists.txt`:\n\n // Use a relative or absolute path. For example, /home/yourusername/gamesdk\n // or C:\\Android\\gamesdk.\n include(\"\u003cvar translate=\"no\"\u003epath/to/gamesdk\u003c/var\u003e/samples/gamesdk.cmake\")\n\n2. Call the `add_gamesdk_target` function with the folder containing\n the gamesdk:\n\n // Use a relative or absolute path.\n add_gamesdk_target(PACKAGE_DIR \u003cvar translate=\"no\"\u003epath/to/gamesdk\u003c/var\u003e)\n\n3. In your `target_link_libraries` for your native library, add\n `oboe` as a dependency:\n\n // The casing of OpenSLES is important.\n target_link_libraries(native-lib oboe OpenSLES ...) \n\nFor advanced usage of CMake, see the [`gamesdk.cmake`](https://android.googlesource.com/platform/frameworks/opt/gamesdk/+/refs/heads/master/samples/gamesdk.cmake)\nsource file.\n\nNext steps: using Oboe\n----------------------\n\nTo play or record audio with Oboe, create and activate one or more audio\nstreams, and use callbacks to exchange audio between your audio input/output\ndevices and your app. See [Using\nOboe](https://github.com/google/oboe/blob/master/docs/GettingStarted.md#using-%0Aoboe)."]]