android gradle php shell ubuntu

Failed to load native library ‘’ for Linux amd64

First off, if this belongs on Ask Ubuntu, my apologies…I’m not really sure what forum this falls under.

I’m attempting to fork and build an Android project from Github using PHP and a shell script. Basically, I’m printing out some output from a shell script I wrote into a website. When you visit the page, and press some buttons, the project is forked and built using Gradle. The PHP code runs the shell script, and then prints the output into the browser as the command runs.

However, I am getting this error as the output of my script:

FAILURE: Build failed with an exception.
* What went wrong:
Failed to load native library '' for Linux amd64.

The script is simply running gradle build for now but I intend to change that later…right now, I’m just working on building the root project and outputting the result.

Here’s the output if I run the command with the --stacktrace flag:

* Exception is:
net.rubygrapefruit.platform.NativeException: Failed to load native library '' for Linux amd64.
at net.rubygrapefruit.platform.internal.NativeLibraryLoader.load(
at net.rubygrapefruit.platform.Native.init(
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(
at org.gradle.launcher.cli.ExceptionReportingAction.execute(
at org.gradle.launcher.cli.ExceptionReportingAction.execute(
at org.gradle.launcher.Main.doAction(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(
at org.gradle.launcher.GradleMain.main(
Caused by: No such file or directory
at Method)
at net.rubygrapefruit.platform.internal.NativeLibraryLocator.find(
at net.rubygrapefruit.platform.internal.NativeLibraryLoader.load(
... 16 more

And here is the output with the --debug flag:

06:21:43.710 [ERROR] [org.gradle.BuildExceptionReporter] 
06:21:43.740 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception.
06:21:43.747 [ERROR] [org.gradle.BuildExceptionReporter]
06:21:43.747 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
06:21:43.748 [ERROR] [org.gradle.BuildExceptionReporter] Failed to load native library '' for Linux amd64.
06:21:43.749 [ERROR] [org.gradle.BuildExceptionReporter]
06:21:43.750 [ERROR] [org.gradle.BuildExceptionReporter] * Exception is:
06:21:43.752 [ERROR] [org.gradle.BuildExceptionReporter] net.rubygrapefruit.platform.NativeException: Failed to load native library '' for Linux amd64.
06:21:43.753 [ERROR] [org.gradle.BuildExceptionReporter] at net.rubygrapefruit.platform.internal.NativeLibraryLoader.load(
06:21:43.753 [ERROR] [org.gradle.BuildExceptionReporter] at net.rubygrapefruit.platform.Native.init(
06:21:43.754 [ERROR] [org.gradle.BuildExceptionReporter] at
06:21:43.754 [ERROR] [org.gradle.BuildExceptionReporter] at
06:21:43.755 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(
06:21:43.756 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(
06:21:43.756 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.cli.ExceptionReportingAction.execute(
06:21:43.756 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.cli.ExceptionReportingAction.execute(
06:21:43.757 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.Main.doAction(
06:21:43.758 [ERROR] [org.gradle.BuildExceptionReporter] at
06:21:43.759 [ERROR] [org.gradle.BuildExceptionReporter] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
06:21:43.759 [ERROR] [org.gradle.BuildExceptionReporter] at sun.reflect.NativeMethodAccessorImpl.invoke(
06:21:43.760 [ERROR] [org.gradle.BuildExceptionReporter] at sun.reflect.DelegatingMethodAccessorImpl.invoke(
06:21:43.760 [ERROR] [org.gradle.BuildExceptionReporter] at java.lang.reflect.Method.invoke(
06:21:43.761 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(
06:21:43.761 [ERROR] [org.gradle.BuildExceptionReporter] at
06:21:43.762 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.GradleMain.main(
06:21:43.762 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: No such file or directory
06:21:43.763 [ERROR] [org.gradle.BuildExceptionReporter] at Method)
06:21:43.763 [ERROR] [org.gradle.BuildExceptionReporter] at
06:21:43.764 [ERROR] [org.gradle.BuildExceptionReporter] at net.rubygrapefruit.platform.internal.NativeLibraryLocator.find(
06:21:43.764 [ERROR] [org.gradle.BuildExceptionReporter] at net.rubygrapefruit.platform.internal.NativeLibraryLoader.load(
06:21:43.765 [ERROR] [org.gradle.BuildExceptionReporter] ... 16 more
06:21:43.765 [ERROR] [org.gradle.BuildExceptionReporter]

I did some research on this matter and found this forum post, but it didn’t give me any leads as to how to fix the issue.

Further research led me to a Github issue, which appears to be for NixOS, but I’m running Ubuntu 12.04 CLI. Also, I should mention I’m running Gradle 2.10 as well.

I also tried running gradle -Dorg.gradle.native=false build as well, but the outcome was the same.

Now, as far as what user is calling the script, I believe it is www-data as I’m running an Apache2 web server and PHP.

Here’s a little snippet of the PHP code that runs the script, which I found on another SO post:

$command = "sh /home/andrew/scripts/ 2>&1";
while (@ ob_end_flush()); // end all output buffers if any
$proc = popen($command, 'r');
echo '<pre style="border-radius: 5px; padding:4px; color:black; background:#ffffff" align="left">';
while (!feof($proc)){
echo fread($proc, 1024);
@ flush();
echo '</pre>';

I’m at a loss now, so I’m hoping someone can lead me to a new, reliable answer.