There are two ways to incorporate the Oboe library into your project.
Integrate Oboe with Gradle and CMake
These instructions are for projects using Android Gradle plugin version 4.1.0 or higher using native dependencies 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.
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.
Add the
oboedependency to thedependenciessection. If necessary, replace1.5.0with the latest stable version of Oboe:dependencies { implementation 'com.google.oboe:oboe:1.5.0' }Enable the
prefaboption in thebuildFeaturessection.android { buildFeatures { prefab true } }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.
Add the following
find_packagecommand:find_package (oboe REQUIRED CONFIG)Add
oboe::oboeto the list of libraries passed to thetarget_link_librariescommand associated with your main executable.
Integrate with the Android Game SDK
Download the library and check it into your source control system.
Make the following changes to your project's build settings.
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:
- Add
gamesdk/includeto your compiler include paths. 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_ReleaseAdd
-loboe_staticto 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:
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.
Add a path of the following form in your linker library paths:
gamesdk/libs/architectureAPIapiLevelNDKndkVersion_stlVersion_Release/lib/oboe
Add
-loboe -lOpenSLESto 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:
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")Call the
add_gamesdk_targetfunction with the folder containing the gamesdk:// Use a relative or absolute path.
add_gamesdk_target(PACKAGE_DIR path/to/gamesdk)In your
target_link_librariesfor your native library, addoboeas a dependency:// The casing of OpenSLES is important.
target_link_libraries(native-lib oboe OpenSLES ...)
For advanced usage of CMake, see the 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.