Gradle app:preBuild FAILED while executing from PHP


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


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

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

What can cause this error? Please help me