Apache Ant error on Yosemite

Hi there,

So the 4.7 supports packaging for Android using Mac editor now. But I just can’t seem to get it packed. I’ve installed the TADP in the engine folder and set up Android SDK in project settings, like in this pic:

I created an empty project and put one of my own static mesh into it and tried packing. It just fails and here’s the log that seems related:

MainFrameActions: Packaging (Android (All)): ====2015/5/8 14:28:25====PERFORMING FINAL APK PACKAGE OPERATION================================================
MainFrameActions: Packaging (Android (All)): UEDeployAndroid.RunCommandLineProgramAndThrowOnError: Making .apk with Ant... (note: it's safe to ignore javac obsolete warnings)
MainFrameActions: Packaging (Android (All)): Error: JAVA_HOME is not defined correctly.
MainFrameActions: Packaging (Android (All)):   We cannot execute /System/Library/Frameworks/JavaVM.framework/Home/bin/java
MainFrameActions: Packaging (Android (All)): BuildCommand.Execute: ERROR: BUILD FAILED
MainFrameActions: Packaging (Android (All)): Program.Main: ERROR: AutomationTool terminated with exception:
MainFrameActions: Packaging (Android (All)): Program.Main: ERROR: Exception in UnrealBuildTool: ERROR: /bin/sh failed with args -c '"/Users/vito0719/NVPACK/apache-ant-1.8.2/bin/ant" -quiet debug'
MainFrameActions: Packaging (Android (All)): Stacktrace:   at UnrealBuildTool.Android.UEDeployAndroid.RunCommandLineProgramAndThrowOnError (System.String WorkingDirectory, System.String Command, System.String Params, System.String OverrideDesc, Boolean bUseShellExecute) [0x00000] in :0 
MainFrameActions: Packaging (Android (All)):   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 
MainFrameActions: Packaging (Android (All)):   at UnrealBuildTool.Android.UEDeployAndroid.PrepForUATPackageOrDeploy (System.String ProjectName, System.String ProjectDirectory, System.String ExecutablePath, System.String EngineDirectory, Boolean bForDistribution, System.String CookFlavor, Boolean bIsDataDeploy) [0x00000] in :0 
MainFrameActions: Packaging (Android (All)):   at AndroidPlatform.Package (AutomationTool.ProjectParams Params, DeploymentContext SC, Int32 WorkingCL) [0x00000] in :0 
MainFrameActions: Packaging (Android (All)):   at Project.Package (AutomationTool.ProjectParams Params, Int32 WorkingCL) [0x00000] in :0 
MainFrameActions: Packaging (Android (All)):   at BuildCookRun.DoBuildCookRun (AutomationTool.ProjectParams Params) [0x00000] in :0 
MainFrameActions: Packaging (Android (All)):   at BuildCookRun.ExecuteBuild () [0x00000] in :0 
MainFrameActions: Packaging (Android (All)):   at BuildCommand.Execute () [0x00000] in :0 
MainFrameActions: Packaging (Android (All)): Program.Main: ERROR: ERROR: /bin/sh failed with args -c '"/Users/vito0719/NVPACK/apache-ant-1.8.2/bin/ant" -quiet debug'
MainFrameActions: Packaging (Android (All)): ProcessManager.KillAll: Trying to kill 0 spawned processes.
MainFrameActions: Packaging (Android (All)): Program.Main: AutomationTool exiting with ExitCode=1
MainFrameActions: Packaging (Android (All)): Domain_ProcessExit
MainFrameActions: Packaging (Android (All)): ProcessManager.KillAll: Trying to kill 0 spawned processes.
MainFrameActions: Packaging (Android (All)): RunUAT ERROR: AutomationTool was unable to run successfully.

I see a lot of errors but I don’t know which one is causing it. Plz help.

OMG that’s a messy log… it was much more readable when I was editing…

just tried an empty project. same result.

Ehi Vito! Try posting your log as code, it will be much clear.

As concern your problem: if you open a terminal can you run the command “java”?

The problem seems to be this one:

Error: JAVA_HOME is not defined correctly. MainFrameActions: Packaging (Android (All)): We cannot execute /System/Library/Frameworks/JavaVM.framework/Home/bin/java

The JAVA_HOME variable indeed is not indispensable, I don’t have it in my shell but I can package anyway.
I would try to fix this first, you probably just need to install the java optional package (not included by default anymore in Yosemite)

Check out this article for more info:

It does look better in code mode, thanks.

I can run “java” in command, it shows a lot of directions on how I should use this command. And I have actually installed Java SE Developer Kit 1.7, which is a prerequisite for installing the TADP tools.

I remember reading a post saying that JAVA_HOME is only used on windows. A staff said so here.

What happens if you open a terminal al type “/Users/vito0719/NVPACK/apache-ant-1.8.2/bin/ant”?

It says:
Error: JAVA_HOME is not defined correctly.
We cannot execute /System/Library/Frameworks/JavaVM.framework/Home/bin/java

ok…what is the output of “which java”?

It prints “/usr/bin/java”

Try setting JAVA_HOME in ~/.bash_profile:
export JAVA_HOME=/usr//java_home

(by the way, what is the output of the command /usr//java_home?)

It isn’t required by UE, but apparently is apache-ant that we need to have working, first…

Hi vito_BumpingWorkshop ,

Try setting your Android SDK to ‘android-19’ instead of ‘latest’. Then, restart your computer as you have made changes to your SDK. See if that helps.

The output would be /Library/Java/JavaVirtualMachines/jdk1.7.0_76.jdk/Contents/Home and I set JAVA_HOME as you suggested but still no luck… Same error showed up in the log…

No it didn’t. “latest” and the option under it were set this way by default. I had to choose the first three options(location of SDK, NDK and ANT) manually though. Hopefully I’ve set them right.

Try uninstalling ant and then reinstalling it. I’m working with Yosemite, same ant version and same java version. Running and from command line should give you the following result:

xxxx-MacBook-Pro:~ xxxx$ ant
Buildfile: build.xml does not exist!
Build failed

Hi devel.bmad,

Thank you for helping. I didn’t have any chance to reinstalling until now. But I still get error report when packaging for Android. I’m using Yosemite too and have the exact same result when I run ant from terminal.

Hi,

Here is what your environment variable setup should look like for packaging for Android: Android Development Basics for Unreal Engine | Unreal Engine 5.1 Documentation

Hi ,

I’ve checked my settings and it seems that apart from some difference in version(my Java is 1.7 and NDK is r10), I’ve got everything right.

Unless I was wrong about how to change environment variable in OS X… I used terminal and typed nano .bash_profile and edit it so it’s exactly as the document instructed(actually they were all there and I only added a JAVA_HOME line which is allegedly windows only) and then I ran source .bash_profile

Is there any problem with this approach?

The approach is fine, if you want just type export in the terminal to check al the variables.

Your problema, as I wrote, is with Ant not working properly. Try re-installing it (just Ant, not UE4) with TADP and try running it from the terminal

I’ve actually re-downloaded and re-installed all the TADP components, but still no luck…