SeeLook / ogg-vorbis-libraries-android

libogg and libvorbis libraries for Android

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

libogg and libvorbis libraries for Android

Presentation

This project provides static libogg and libvorbis libraries, and also allows you to compile them on your own, using build.sh.

Usage

To compile the libraries and generate the headers, here is how you can proceed (tested on Linux Ubuntu 16.04.5):

  1. Download the Android NDK here: https://developer.android.com/ndk/downloads/, and choose Linux 64-bit (x86) (tested with version r18b)
  2. Unzip the Android NDK in your home directory, and name it android-ndk
  3. Clone this project, also in your home directory, and go in it (in ogg-vorbis-libraries-android)
  4. In the ogg-vorbis-libraries-android directory, open a terminal
  5. Add the ndk-build in your PATH, by typing: PATH=${PATH}:/home/<your_user_name>/android-ndk/build
  6. Then, chmod +x ./build.sh
  7. Finally, compile everything by typing: ./build.sh

Implementation in an Android project

To implement the libraries and the headers in an Android project, here is how you can proceed (tested on Android Studio 3.2.1):

  1. Create a new Android project with "Include C++ support"
  2. In your cpp folder, create a new package vorbis
  3. From this project, copy the lib directory and paste it in the vorbis directory in your project
  4. 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
  5. In your app/build.gradle file, add the following in the android > defaultConfig > externalNativeBuild > cmake bloc:
    abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
    
  6. In your CMakeLists.txt file, add the following:
    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)
    
    and in the target_link_libraries bloc, add these two lines:
    ${vorbis_DIR}/lib/${ANDROID_ABI}/libogg.a
    ${vorbis_DIR}/lib/${ANDROID_ABI}/libvorbis.a
    

At this point, it should compile and run.

About

libogg and libvorbis libraries for Android

License:MIT License


Languages

Language:C 94.4%Language:Makefile 3.0%Language:Shell 2.6%