- For simplicity sake, this code is licensed under the same license as the libvorbis library from http://xiph.org/vorbis/
- This project is highly inspired from https://github.com/MoNTE48/libvorbis-android
This project provides static libogg and libvorbis libraries, and also allows you to compile them on your own, using build.sh.
To compile the libraries and generate the headers, here is how you can proceed (tested on Linux Ubuntu 16.04.5):
- Download the Android NDK here: https://developer.android.com/ndk/downloads/, and choose Linux 64-bit (x86) (tested with version r18b)
- Unzip the Android NDK in your home directory, and name it android-ndk
- Clone this project, also in your home directory, and go in it (in ogg-vorbis-libraries-android)
- In the ogg-vorbis-libraries-android directory, open a terminal
- Add the ndk-build in your PATH, by typing:
PATH=${PATH}:/home/<your_user_name>/android-ndk/build
- Then,
chmod +x ./build.sh
- Finally, compile everything by typing:
./build.sh
To implement the libraries and the headers in an Android project, here is how you can proceed (tested on Android Studio 3.2.1):
- Create a new Android project with "Include C++ support"
- In your cpp folder, create a new package vorbis
- From this project, copy the lib directory and paste it in the vorbis directory in your project
- In each subdirectory (arm64-v8a, armeabi-v7a, x86 and x86_64), create an include directory and, from this project, copy the ogg and vorbis that are in the inc directory, and paste them in the include directory you just created
- In your app/build.gradle file, add the following in the android > defaultConfig > externalNativeBuild > cmake bloc:
abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
- In your CMakeLists.txt file, add the following:
and in the target_link_libraries bloc, add these two lines:
set(vorbis_DIR ${CMAKE_SOURCE_DIR}/src/main/cpp/vorbis) add_library(ogg STATIC IMPORTED) set_target_properties(ogg PROPERTIES IMPORTED_LOCATION ${vorbis_DIR}/lib/${ANDROID_ABI}/libogg.a) add_library(vorbis STATIC IMPORTED) set_target_properties(vorbis PROPERTIES IMPORTED_LOCATION ${vorbis_DIR}/lib/${ANDROID_ABI}/libvorbis.a) include_directories(${vorbis_DIR}/lib/${ANDROID_ABI}/include)
${vorbis_DIR}/lib/${ANDROID_ABI}/libogg.a ${vorbis_DIR}/lib/${ANDROID_ABI}/libvorbis.a
At this point, it should compile and run.