UE 4.7.2 can't pack .apk with Ant

Hey guys!
My head is about to blow already, I’ve googled a lot of similar questions, but yet found no solution.
I’m trying to build an android app with UE 4.7.2. And when it comes to final apk creation with Ant, the operation fails.
Actually, I’m totally sure it’s not my project problem, because it’s a totally new built-in top down solution with starter content. I didn’t change or add anything to it, just for the sake of clarity of experiment.
I have installed everything according to this instruction https://docs.unrealengine.com/latest/INT/Platforms/Android/GettingStarted/1/index.html
I’m absolutely sure of all the environment variables from HAVA_HOME to ANT_HOME and other stuff. They’re all set up correctly. And also I have set everything up at project properties → android / android sdk tabs
But for some reason UE can’t start AutomationTool succesfully referencing to some problems at 720 and 734th lines of build.xml.
I’m pretty certain it’s some minor problem which I’m just missing. But since I’m new to UE, I can’t seem to find it myself. So, can anyone point me in the right direction, please?

Here’s the part of log where the problems start https://dl.dropboxusercontent.com/u/25927940/log.txt
p.s. my OS is Windows 7 x64 professional. Hardware’s Intel Core i5 (2.50) + 8 Gb RAM

Here’s the part where it starts to complain about build.xml

MainFrameActions: Packaging (Android (All)): BUILD FAILED
MainFrameActions: Packaging (Android (All)): C:\NVPACK\android-sdk-windows\tools\ant\build.xml:720: The following error occurred while executing this line:
MainFrameActions: Packaging (Android (All)): C:\NVPACK\android-sdk-windows\tools\ant\build.xml:734: Compile failed; see the compiler error output for details.
MainFrameActions: Packaging (Android (All)): Total time: 23 seconds
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: cmd.exe failed with args /c "D:/apache-ant-1.9.0/bin/ant.bat" -quiet debug
MainFrameActions: Packaging (Android (All)): Stacktrace:    at UnrealBuildTool.Android.UEDeployAndroid.RunCommandLineProgramAndThrowOnError(String WorkingDirectory, St
MainFrameActions: Packaging (Android (All)): ring Command, String Params, String OverrideDesc, Boolean bUseShellExecute)
MainFrameActions: Packaging (Android (All)):    at UnrealBuildTool.Android.UEDeployAndroid.MakeApk(String ProjectName, String ProjectDirectory, String OutputPath, String EngineDirectory, Boolean bForDistribution, String CookFlavor, Boolean bMakeSeparateApks, Boolean bIncrementalPackage, Boolean bDisallowPackagingDataInApk)
MainFrameActions: Packaging (Android (All)):    at UnrealBuildTool.Android.UEDeployAndroid.PrepForUATPackageOrDeploy(String ProjectName, String ProjectDirectory, String ExecutablePath, String EngineDirectory, Boolean bForDistribution, String CookFlavor, Boolean bIsDataDeploy)
MainFrameActions: Packaging (Android (All)):    at AndroidPlatform.Package(ProjectParams Params, DeploymentContext SC, Int32 WorkingCL)
MainFrameActions: Packaging (Android (All)):    at Project.Package(ProjectParams Params, Int32 WorkingCL)
MainFrameActions: Packaging (Android (All)):    at BuildCookRun.DoBuildCookRun(ProjectParams Params)
MainFrameActions: Packaging (Android (All)):    at BuildCommand.Execute()
MainFrameActions: Packaging (Android (All)):    at AutomationTool.Automation.Execute(List`1 CommandsToExecute, CaselessDictionary`1 Commands)
MainFrameActions: Packaging (Android (All)):    at AutomationTool.Automation.Process(String[] CommandLine)
MainFrameActions: Packaging (Android (All)):    at AutomationTool.Program.MainProc(Object Param)
MainFrameActions: Packaging (Android (All)):    at AutomationTool.InternalUtils.RunSingleInstance(MainProc Main, Object Param)
MainFrameActions: Packaging (Android (All)):    at AutomationTool.Program.Main()
MainFrameActions: Packaging (Android (All)): Program.Main: ERROR: ERROR: cmd.exe failed with args /c "D:/apache-ant-1.9.0/bin/ant.bat" -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)): copying UAT log files...
MainFrameActions: Packaging (Android (All)): RunUAT.bat ERROR: AutomationTool was unable to run successfully.
MainFrameActions: Packaging (Android (All)): BUILD FAILED

I’ve solved the problem myself.
What I did: ran cmd → ant debug -f “here goes path to build.xml from log”
And it said it cannot find tools.jar in C:\Program Files\Java\jdk1.8.0_40 and it confused me right away cause apparently the file was there. So the first thought that came to my mind is that the problem in a space between Program and Files, so I just copied my JDK to another location, with no spaces in name: C:\Java\jdk1.8.0_40 and also changed my JAVA_HOME environment variable to reflect the new location. Then I went to UE editor → edit → project settings → android sdk and also changed the path there Screenshot by Lightshot
Tried re-build, and BINGO! The large apk file (about ~930 Mb) was packed succesfully

Had the exact same problem, thank you mate

What do you mean by Space between program and file???
build.xml from log??

after run this Command {ant debug -f C:\NVPACK\android-sdk-windows\tools\ant\Build.xml
Getting this massage:

Buildfile: C:\NVPACK\android-sdk-windows\tools\ant\build.xml
[taskdef] Could not load definitions from resource anttasks.properties. It could not be found.
[taskdef] Could not load definitions from resource emma_ant.properties. It could not be found.

-set-mode-check:

-set-debug-files:

-check-env:

BUILD FAILED
C:\NVPACK\android-sdk-windows\tools\ant\build.xml:396: Problem: failed to create task or type checkenv
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any / declarations have taken place.

What do you mean by Space between program and file???
build.xml from log??

after run this Command {ant debug -f C:\NVPACK\android-sdk-windows\tools\ant\Build.xml
Getting this massage:

Buildfile: C:\NVPACK\android-sdk-windows\tools\ant\build.xml
[taskdef] Could not load definitions from resource anttasks.properties. It could not be found.
[taskdef] Could not load definitions from resource emma_ant.properties. It could not be found.

-set-mode-check:

-set-debug-files:

-check-env:

BUILD FAILED
C:\NVPACK\android-sdk-windows\tools\ant\build.xml:396: Problem: failed to create task or type checkenv
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any / declarations have taken place.