*********************************
* How to build GPAC for Android *
*********************************

To compile GPAC for Android, please execute the following steps:

1) Check out the GPAC GIT repository (but if you read this you probably already checkouted the GPAC repository):
 
	git clone https://github.com/gpac/gpac
	This directory will be reminded as <GPAC_DIR>

Get the extra lib packages from http://download.tsi.telecom-paristech.fr/gpac/gpac_extra_libs.zip and unzip the archive.
This directory will be reminded as <GPAC_EXTRA_DIR>


2) Get the Android softwares:
 
	A. Download the Android NDK at http://developer.android.com/sdk/ndk/index.html and unzip it at a place of your choice (referenced as <ANDROID_NDK_DIR>).
		
	B. Download the Java Development Kit at http://www.oracle.com/technetwork/java/javase/downloads/index-jsp-138363.html (referenced as <JDK_DIR>)
 
	C. One of the following tools i) or ii) are needed for building the Android Package (APK):
		i)  GPAC provides scripts to build the APK from the shell. No IDE is needed.
				You will then ignore every step in this readme that follow the ii) mark (as it concerns only people using Android Studio).

		ii) Android Studio is useful if you want to go beyond the build (ie debug, add features, use the simulator etc). Firstly get Android Studio at https://developer.android.com/studio/index.html
				
 
	D. Get and install SDK Component for Android:
 
		i)  If you build without Android Studio, download the basic Android command line tools at https://developer.android.com/studio/index.html (at the bottom of the page), unzip it and launch tools/android. This opens a window. In "Tools" folder select "Android SDK Build-tools 23.0.3" and "Android API 23", in "Extras" folder select "Android Support Repository" and "Google Repository" and then Install packages  at SDK Path (referenced as <ANDROID_SDK_DIR>).
 
		ii) If you use Android Studio, during installation you should tick the option  Android SDK, so it will be downloaded

3) Compile extra-libs for android 

	A. Unzip all libs
	
		Go to <GPAC_EXTRA_DIR>. Set the right to execute the unzip_all script (e.g. chmod +x unzip_all.sh)
		Run the script as follows :  ./unzip_all

	B. Build all extra-libs
	
		Go to <GPAC_EXTRA_DIR>/build/android. Set the right to execute the script gpac_build_all_extra_libs (e.g. chmod u+x gpac_build_all_extra_libs ).
		Run the script as follows : ./gpac_build_all_extra_libs <ANDROID_NDK_DIR>
	
		NOTE: In case there is an error compiling ffmpeg, make sure there is permission to execute the script compile_ffmpeg_android as well (e.g. chmod u+rxw compile_ffmpeg_android)
	
 	C. Copy all the compiled extra lib to the right folder
	
		Go back to <GPAC_EXTRA_DIR>
		Copy the just compiled libs into <GPAC_DIR>/extra_lib/lib/android by entering this command : 
		cp -r lib/android/* <GPAC_DIR>/extra_lib/lib/android/

4) Building GPAC for Android
 
	(optional) 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_DIR> */
		* sudo ln -s /home/xxx/xxx/<Android NDK> android_ndk /* /opt/android_ndk will then become your new <ANDROID_NDK_DIR> */

	i) Building Osmo4.apk without Android Studio

		 Go to GPAC_DIR/build/android/jni and launch the script 
		./gpac_build_android -ndk=<ANDROID_NDK_DIR> -sdk=<ANDROID_SDK_DIR> -jdk=<JDK_DIR>
		It will generate the package Osmo4.apk.
		You can find the APK in <GPAC_DIR>/applications/osmo4_android_studio/app/build/outputs/apk
 
  ii)Building Osmo4.apk with Android Studio

		Go to GPAC_DIR/build/android/jni and launch the script 
		./gpac_build_android <ANDROID_NDK_DIR>
		Open Android Studio, click on "open an existing Android Studio project" and put <GPAC_DIR>/applications/osmo4_android_studio and build project
