There are two ways to incorporate the Oboe library into your project.

- [Integrate Oboe with Gradle and CMake](https://developer.android.com/games/sdk/oboe/update-build-settings#integrate-native)

- [Download the Android Game SDK and integrate Oboe manually](https://developer.android.com/games/sdk/oboe/update-build-settings#integrate-download)

## Integrate Oboe with Gradle and CMake

These instructions are for projects using[Android Gradle plugin version 4.1.0 or higher](https://developer.android.com/studio/releases/gradle-plugin)using[native dependencies](https://developer.android.com/studio/build/dependencies#using-native-dependencies?buildsystem=cmake)with CMake.

If your project is using either the Android Gradle plugin version 4.0 or`ndk-build`instead of CMake, the process is slightly different. See[Using native dependencies](https://developer.android.com/studio/build/dependencies#using-native-dependencies?buildsystem=ndk-build&agpversion=4.0).
| **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](https://developer.android.com/studio/releases/gradle-plugin).

### Update build.gradle

To add Oboe to your app while using Android Gradle plugin version 4.1.0 or higher, make the following additions to your app's`build.gradle`file.

1. Add the`oboe`dependency to the`dependencies`section. If necessary, replace`1.5.0`with the[latest stable version](https://github.com/google/oboe/releases/)of Oboe:

       dependencies {
           implementation 'com.google.oboe:oboe:1.5.0'
       }

2. Enable the`prefab`option in the`buildFeatures`section.

       android {
           buildFeatures {
               prefab true
           }
       }

3. Configure your app to use the shared STL:

       android {
           defaultConfig {
               externalNativeBuild {
                   cmake {
                       arguments "-DANDROID_STL=c++_shared"
                   }
               }
           }
       }

### Update CMakeLists.txt

Adding Oboe requires two additions to your app's`CMakeLists.txt`file.

1. Add the following`find_package`command:

       find_package (oboe REQUIRED CONFIG)

2. Add`oboe::oboe`to the list of libraries passed to the`target_link_libraries`command associated with your main executable.

## Integrate with the Android Game SDK

1. [Download the library](https://developer.android.com/games/sdk)and check it into your source control system.

2. Make the following changes to your project's build settings.

| **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.

### Static library

When you integrate with the Android Game SDK, you statically link to a version of the Oboe library compiled for the given ABI, API level, NDK, and STL combination:

1. Add`gamesdk/include`to your compiler include paths.
2. Add a path of the following form in your linker library paths:

   ```
   gamesdk/libs/architecture_APIapiLevel_NDKndkVersion_stlVersion_Release
   ```

   For example:`gamesdk/libs/arm64-v8a_API24_NDK18_cpp_static_Release`
3. Add`-loboe_static`to your linker command.

You don't need to bundle the`liboboe.so`shared library, which means static linking gives you a much smaller code footprint.

### Shared library

If the ABI, API level, NDK, and STL combination required for a static library isn't available for your settings, you can link against the shared library instead:

1. Follow steps 1 and 2 from the previous section (about the static library) to update your compiler include paths, and use the appropriate header file.

2. Add a path of the following form in your linker library paths:

   <br />

   ```
   gamesdk/libs/architectureAPI<var translate="no">apiLevel</var>NDKndkVersion_stlVersion_Release/lib/oboe
   ```
3. Add`-loboe -lOpenSLES`to your linker command.

### Using CMake (static library only)

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:

1. Include this file in your`CMakeLists.txt`:

       // Use a relative or absolute path. For example, /home/yourusername/gamesdk
       // or C:\Android\gamesdk.
       include("<var translate="no">path/to/gamesdk</var>/samples/gamesdk.cmake")

2. Call the`add_gamesdk_target`function with the folder containing the gamesdk:

       // Use a relative or absolute path.
       add_gamesdk_target(PACKAGE_DIR <var translate="no">path/to/gamesdk</var>)

3. In your`target_link_libraries`for your native library, add`oboe`as a dependency:

       // The casing of OpenSLES is important.
       target_link_libraries(native-lib oboe OpenSLES ...) 

For advanced usage of CMake, see the[`gamesdk.cmake`](https://android.googlesource.com/platform/frameworks/opt/gamesdk/+/refs/heads/master/samples/gamesdk.cmake)source file.

## Next steps: using Oboe

To play or record audio with Oboe, create and activate one or more audio streams, and use callbacks to exchange audio between your audio input/output devices and your app. See[Using Oboe](https://github.com/google/oboe/blob/master/docs/GettingStarted.md#using-%0Aoboe).