Build UE 4.7.3 with Android support

Hi, I’m trying to build the UE Editor on mac with Android support, but setup.command is not detecting the android SDK or NDK:

   Checking dependencies (excluding Win32, Win64, HTML5, Android)...

I’ve installed the Android SDK and NDK without using TAPD because I’m already regularly developing for Android.
Please note that with the binary distribution of UE I can properly package my projects for Android.

This is my .bash_profile, what am I missing?

export PATH=$PATH:/Users/xxx/NVPACK/apache-ant-1.8.2/bin
export ANT_HOME=/Users/xxx/NVPACK/apache-ant-1.8.2
export NVPACK_ROOT="/Users/xxx/NVPACK"
export NDK_ROOT=/Developer/Android/android-ndk-r10d
export ANDROID_NDK_ROOT=/Developer/Android/android-ndk-r10d
export ANDROID_SDK_ROOT=/Developer/Android/sdk
export PATH=$PATH:ANDROID_NDK_ROOT=/Developer/Android/android-ndk-r10d

Ok, solved, the variables to include in .bash_profile are named as follow:

export PATH=$PATH:/Developer/Android/android-ndk-r10d
export NDK_ROOT=/Developer/Android/android-ndk-r10d
export NDKROOT=/Developer/Android/android-ndk-r10d

Actually this was not enough, the solution is down in the thread and involves building manually the android files (thank you Michael and Josh!)

cd "/Users/xxx/Documents/Unreal Projects/UnrealEngine"
./Engine/Build/BatchFiles/Mac/Build.sh UE4Game Android Development
./Engine/Build/BatchFiles/Mac/Build.sh UE4Client Android Development

Ok, not quite yet. With the aforementioned env variables I get the message saying that is checking dependencies correct, but after compiling the UE4Editor I can’t see any Android target.
So, when I try to deploy on android devices, I get the following error:

====03/19/2015 17:01:01====PREPARING NATIVE CODE=================================================================
LogPlayLevel: BuildCommand.Execute: ERROR: BUILD FAILED
LogPlayLevel: Program.Main: ERROR: AutomationTool terminated with exception:
LogPlayLevel: Program.Main: ERROR: Exception in UnrealBuildTool: ERROR: Can’t make an APK without the compiled .so [/Users/xxx/Documents/Unreal Projects/UnrealEngine/Engine/Binaries/Android/UE4Game-armv7-es2.so]
LogPlayLevel: Stacktrace: at UnrealBuildTool.Android.UEDeployAndroid.MakeApk (System.String ProjectName, System.String ProjectDirectory, System.String OutputPath, System.String EngineDirectory, Boolean bForDistribution, System.String CookFlavor, Boolean bMakeSeparateApks, Boolean bIncrementalPackage, Boolean bDisallowPackagingDataInApk) [0x00000] in :0
LogPlayLevel: at UnrealBuildTool.Android.UEDeployAndroid.PrepForUATPackageOrDeploy

…or an Alert saying that the UE4Game is missing when packaging.
Is there a log when running setup.command to check what has been configured or shall I rebuild the whole editor at any attempt?

We use three variables: ANDROID_HOME, NDKROOT and ANT_HOME (plus JAVA_HOME, but only on Windows)

ANDROID_HOME should most likely be the same as your ANDROID_SDK_ROOT. Installed with TADP, the folder is called android-sdk-macosx and here’s how it looks:

34955-screen+shot+2015-03-19+at+12.58.09+pm.png

These variables are correctly set now (using TADP), but still I don’t have any Android target platform. Any other check I can do? tools that should be on the path? is there a log of what’s missing to enable android?

export PATH=$PATH:/Users/xxx/NVPACK/apache-ant-1.8.2/bin
export ANT_HOME=/Users/xxx/NVPACK/apache-ant-1.8.2
export NVPACK_ROOT="/Users/xxx/NVPACK"
#export ANDROID_HOME=/Developer/Android/sdk
#export PATH=$PATH:/Developer/Android/sdk/platform-tools/
export PATH=$PATH:/Developer/Android/android-ndk-r10d
export NDK_ROOT=/Developer/Android/android-ndk-r10d
export NDKROOT=/Developer/Android/android-ndk-r10d
export NVPACK_NDK_VERSION=android-ndk-r10d
export PATH=$PATH:/Users/xxx/NVPACK/android-sdk-macosx/tools
export ANDROID_HOME=/Users/xxx/NVPACK/android-sdk-macosx
export PATH=$PATH:/Users/xxx/NVPACK/android-sdk-macosx/platform-tools
export PATH=$PATH:/Users/xxx/NVPACK/android-sdk-macosx/build-tools
export PATH=$PATH:/Users/xxx/NVPACK/android-sdk-macosx/extras/android/support-tools

Just to double check, if everything was ok should I see “UE4Game - Android” among these options? How can I debug this problem?

34962-screen+shot+2015-03-19+at+19.38.27.png

Unfortunately, we don’t have any support for building for Android from Xcode, so no, you shouldn’t see UE4Game - Android in there. Currently you can only build Android binaries using command line tools (like Build.sh in Engine/Build/BatchFiles/Mac or from the UE4 editor).

Ok, that’s not a problem. All I want is packaging from inside the UE4Editor, but I need to compile it from the github source. In the version I built there is no Android folder in the Engine/Binaries folder (though the environment variables should be correct now)

I mean, these are the files I find in the UE binary version which are missing from the one I compile from source:

You don’t need these files in a build compiled from source. I believe that all necessary binaries should get build as part of packaging, but I’m not sure if that’s also the case for blueprint-only projects. I’ll check and get back to you.

Thank you. Launching on an android device displays the following error:
Program.Main: ERROR: Exception in UnrealBuildTool: ERROR: Can’t make an APK without the compiled .so [/Users/xxx/Documents/Unreal Projects/UnrealEngine/Engine/Binaries/Android/UE4Game-armv7-es2.so]

So at least some of these files are probably necessary.
On windows you have to compile selecting “Development Client” and “Android” build target, I would need to understand how to do that on mac:

You could try this:

cd "/Users/xxx/Documents/Unreal Projects/UnrealEngine"

./Engine/Build/BatchFiles/Mac/Build.sh UE4Game Android Development

./Engine/Build/BatchFiles/Mac/Build.sh UE4Client Android Development

Great, the compilation worked! Is the whole process documented somewhere?

There’s still something missing though… now in the Android folder I have the following files:
cd Engine/Binaries/Android/
Lucas-MacBook-Pro:Android unstable$ ls
UE4Client-armv7-es2.apk UE4Game-armv7-es2.apk
UE4Client-armv7-es2.so UE4Game-armv7-es2.so

But for my project I need the OpenGL es31 version, I can I compile it?

LogPlayLevel: Program.Main: ERROR: Exception in UnrealBuildTool: ERROR: Can’t make an APK without the compiled .so [/Users/xxx/Documents/Unreal Projects/UnrealEngine/Engine/Binaries/Android/UE4Game-armv7-es31.so]

I’m glad it worked. I don’t know if this is documented nor how to force building ES31 binaries, but I’ll make sure someone who knows answers you.

If you are using a Content Only project, it turns out that there’s not a “nice” way to compile ES31. The way to do it is to manually open Config/BaseEngine.ini, and set bBuildForES31 to true, then build UE4Game for Android.

Note that ES31 is actually ES31 + AEP, so your device needs Android Extension Pack support, and this is pretty early. Not many devices with AEP have been tested, and it actually will only cook DXT textures when you package for the ES31+AEP target.

In 4.8, ES31+AEP is no longer a Target Platform, it is driven solely by the checkbox, and will Just Work ™. Also, with a content only project, it will recompile the executable with ES31 support (into your project’s directory).

Josh

Ok, great, good to know! Thank you both, you have been very helpful :slight_smile:

How do you have access to ./Engine/Build/BatchFiles/Mac/Build.sh UE4Game Android Development at cd “/Users/xxx/Documents/Unreal Projects/UnrealEngine”

Or rather what are the perquisites to do this? Do we need anything not specifically mentioned?

“./Engine/Build/BatchFiles/Mac/Build.sh” is a script, if you downloaded the source code of the engine from github you can find it in the path above. The other path refers to the location of the source code three.

Would this be any different to for building on OUYA with mac.