Compiling GPAC for Android

To compile GPAC for Android under Ubuntu (version >= 12.04), please execute the following steps:


1.1.Download and unzip Android SDK

Download and unzip the latest version at

1.2.Download and unzip NDK Android

Download and unzip the latest version at


sudo apt-get install ant

1.4.Get and install SDK Component for Android

Launch /tools/android. This opens a window. On the left panel, click on “Available packages”, select “Android Repository” and then “Install Selected”.

1.5. [Optional] Install Eclipse IDE

Firstly get Eclipse for java at Then get the ADT (Android Development Tools) plug-in in order to allow Eclipse to interact with Android tools at and follow the instructions. For installing Android SDK components, go to Eclipse Select Window->Preferences->Android and put the SDK directory path. Then select Window > Android SDK and AVD Managergo get the packages (Android repository packages are needed. The third party ones depends on the target devices

1.6.Get GPAC project

1.7.Links the Android SDK and NDK directories

cd /opt/
sudo ln -s /home/xxx/xxx/<Android SDK> android_sdk # /opt/android_sdk will then become your new <Android SDK>
sudo ln -s /home/xxx/xxx/<Android NDK> android_ndk # /opt/android_ndk will then become your new <Android NDK>

1.8.Get all extra-libs

1.8.1. Compiling from source code

  • Get extra_libs source code from here. Then, goto /build/android and run the script:
    ./gpac_build_all_extra_libs <Android_NDK_DIR>

    Note: you need to set the right to execute the script (i.e: chmod a+x) to the sh scripts if they ask

  • When the compilation finishes without error, go to <GPAC_EXTRA_DIR> and copy the compiled extra-libs into <GPAC_DIR>/extra_lib/libs/android

    1.8.2. Using pre-compiled extra-libs

    Get pre-compiled extra-libs from here


    Go to GPAC_DIR/build/android/jni and launch the script:

     ./gpac_build_android -ndk=<Android_NDK_DIR> -sdk=<Android_SDK_DIR> -ant=<ANT_DIR> [-force-rebuild]

    By default, it will generate the package Osmo4-[VERSION]-[BRANCH].apk in GPAC_DIR (referenced as YOUR_OSMO4.apk)

    3.Debuging using adb tool

    3.1.Setup the environmental variable

    Open ~/.bashrc using an editor and add these lines to the end of it:

    export ANDROID_HOME=/opt/android-sdk-linux
    export PATH=$ANDROID_HOME/tools:$PATH
    export PATH=$ANDROID_HOME/platform-tools:$PATH

    You should recharge your .bashrc for updating your changes:

    source ~/.bashrc

    3.2.Some useful commands

    First you need to connect your phone with the computer and enable Usb Debugging Mode (refer)

  • List the devices connected to this computer
  • adb devices
  • Install GPAC to your connected device: cd to GPAC_DIR then run
  • adb install -r YOUR_OSMO4.apk
  • Get the logs
  • adb logcat -c && adb logcat > [LOGCAT_OUTPUT_FILE]
  • Sometimes you can get a segmentfault exception. For dumping the error message, use the command
  • ./ndk-stack -sym GPAC_DIR/build/android/obj/local/[armeabi/armeabi-v7a] -dump [LOGCAT_OUTPUT_FILE] > [DUMP_OUTPUT_FILE]
  • Start Osmo4 from command-line
  • adb shell am start -n com.gpac.Osmo4/.Osmo4 [URL]

    4.Common issues

  • If you have a problem with the execusing of aapt you need to install 32-bit libraries
  • sudo apt-get install gcc-multilib lib32z1 lib32stdc++6
  • GitHub issues