Gradle app:preBuild FAILED while executing from PHP

Hello,

I´m trying to build my applications from PHP, but I´m facing a weired problem.

Executing the build script from shell works like a charm, but from PHP I get

:app:preBuild FAILED

BUILD FAILED

This is the debug log, at least the part where the error occurs:

http://pastebin.com/diDD0ddG

The project folders all have permission 777 and the user and group is www-data.

What can cause this error? Please help me