Android building in Linux (somewhat of a tutorial)

Ive been working on this and i thought i would share what ive got so far,

install current jdk for your distro, open jdk seems to work fine.

get the tadp package for you distro from nvidia. eg: “tadp-4.0r1-linux-x64.run”

it will make life a wee bit easier on you, it even updates your ~/.bashrc for you.
install, defaults should be fine.

next a logout and in may be needed, not to sure about that, but it couldnt hurt.

now we have to do a little editing to some files.
I edited my Engine/Build/BatchFiles/Linux/Build.sh

adding the Path exports for the android sdk eg:


#!/bin/sh

# This script gets can be used to build clean individual projects using UnrealBuildTool

set -e

export PATH=$PATH:"/home/angelo/NVPACK/android-sdk-linux/tools"
export ANDROID_HOME="/home/angelo/NVPACK/android-sdk-linux"

export PATH=$PATH:"/home/angelo/NVPACK/android-sdk-linux/platform-tools"

export PATH=$PATH:"/home/angelo/NVPACK/android-sdk-linux/build-tools"

export PATH=$PATH:"/home/angelo/NVPACK/android-sdk-linux/extras/android/support-tools"

export PATH=$PATH:"/home/angelo/NVPACK/android-ndk-r10d"

export NDK_ROOT="/home/angelo/NVPACK/android-ndk-r10d"
export NDKROOT="/home/angelo/NVPACK/android-ndk-r10d"
export NVPACK_NDK_VERSION="android-ndk-r10d"
export NDK_STANDALONE_46_ANDROID9_32="/home/angelo/NVPACK/android-ndk-r10d/toolchains/arm-linux-androideabi-4.6/gen_standalone/linux-x86_64"
export NDK_STANDALONE_46_ANDROID9_64="/home/angelo/NVPACK/android-ndk-r10d/toolchains/aarch64-linux-android-4.9/gen_standalone/linux-x86_64"

export PATH=$PATH:"/home/angelo/NVPACK/apache-ant-1.8.2/bin"
export ANT_HOME="/home/angelo/NVPACK/apache-ant-1.8.2"

export PATH=$PATH:"/home/angelo/NVPACK/gradle-2.2.1/bin"
export GRADLE_HOME="/home/angelo/NVPACK/gradle-2.2.1"
export CUDA_TOOLKIT_ROOT_6_5="/home/angelo/NVPACK/cuda-6.5"

export PATH=$PATH:"/home/angelo/NVPACK/cuda-7.0/bin"
export CUDA_TOOLKIT_ROOT="/home/angelo/NVPACK/cuda-7.0"
export CUDA_TOOLKIT_ROOT_7_0="/home/angelo/NVPACK/cuda-7.0"

export NVPACK_ROOT="/home/angelo/NVPACK"

you may not need to do this.

in Engine/Source/Programs/UnrealBuildTool/Android/AndroidToolChain.cs
at line 226 after


string ArchitecturePathMac = @"prebuilt/darwin-x86_64";

add:


string ArchitecturePathLinux = @"prebuilt/linux-x86_64";

then a little further down find


			else if (Directory.Exists(Path.Combine(NDKPath, ArchitecturePathMac)))
			{
				Log.TraceVerbose("        Found Mac versions of toolchain");
				ArchitecturePath = ArchitecturePathMac;
				ExeExtension = "";
			}

and add


			else if (Directory.Exists(Path.Combine(NDKPath, ArchitecturePathLinux)))
			{
				Log.TraceVerbose("        Found Linux versions of toolchain");
				ArchitecturePath = ArchitecturePathLinux;
				ExeExtension = "";
			}

directly after.
this remedies being unable to find the android toolchain.

now, since linux is Very Case sensitive,
we need to edit 2 more files.
open Engine/Source/Runtime/Core/Private/Android/AndroidFile.cpp

and fix the 2 includes at the top.
they should be lower case like so…


#include <android/asset_manager.h>
#include <android/asset_manager_jni.h>

next open Engine/Source/Runtime/Launch/Private/Android/AndroidJNI.cpp
and fix those as well:


#include <android/asset_manager.h>
#include <android/asset_manager_jni.h>

dont forget to save.

as of this moment you also need to copy over
libvorbis.a
libvorbisenc.a
libvorbisfile.a
from Engine/Source/ThirdParty/Vorbis/libvorbis-1.3.2/lib/Android/
(there are 3 folders there, make sure you match the architecture you are building for)
to
~/NVPACK/android-ndk-r10d/platforms/android-19/+YOUR architecture+/usr/lib/
that will take care of missing libs.

now you can issue:
./Engine/Build/BatchFiles/Linux/Build.sh UE4Game Android Development
./Engine/Build/BatchFiles/Linux/Build.sh UE4Client Android Development
and they will build

I have yet to package and push it to my device, i will attempt that later this evening, but this is a big chunk of what was holding me back so far.

hopefully someone will find this useful, and i will post my findings, when i try to get it on my device.
angelo aka angjminer.