Android SDK Detection - Failed java version detection for '/usr/lib/jvm/java-8-oracle/bin/java'

Background: I guess this attempt might be too crazy :wink: but I’m building for GearVR in Ubuntu 16.04, in AWS, headless. Currently using 5.4.0f3.

I can run editor tests, and even build our “Android Mono” target using xvfb-run, and -quit -batchmode -nographics. This yields an apk file that installs and launches, but the crashes straightaway, which is fine, it’s not a real target.

But when I try to build for GearVR, it falls over in the “Android SDK Detection” phase.

The error message I get is Failed java version detection for '/usr/lib/jvm/java-8-oracle/bin/java', which is the full path to the java binary. The output of /usr/lib/jvm/java-8-oracle/bin/java -version is:

java version “1.8.0_101”
Java™ SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot™ 64-Bit Server VM (build 25.101-b13, mixed mode)

and, likewise, javac:

javac 1.8.0_101

This also happened with OpenJDK, which is why I tried Oracle, but alas.

I have ANDROID_SDK_ROOT, JAVA_HOME, JAVA_SDK_ROOT, and everything added in PATH, set in environment variables. Also, the build script explicitly loads these through EditorPrefs.SetString(string, string);

So, I guess the question is:

How does Android SDK Detection work, and/or what can I do to fix this?

Full exception and stack trace:

Unhandled Exception: System.InvalidOperationException: Process has not been started.
at System.Diagnostics.Process.get_HasExited () [0x00000] in :0
at (wrapper remoting-invoke-with-check) System.Diagnostics.Process:get_HasExited ()
at UnityEditor.Utils.ProcessOutputStreamReader+c__AnonStoreyCD.<>m__266 () [0x00000] in /home/builduser/buildslave/unity/build/Editor/Mono/Utils/ProcessOutputStreamReader.cs:16
at UnityEditor.Utils.ProcessOutputStreamReader.ThreadFunc () [0x00000] in /home/builduser/buildslave/unity/build/Editor/Mono/Utils/ProcessOutputStreamReader.cs:32
Failed java version detection for ‘/usr/lib/jvm/java-8-oracle/bin/java’
System.IO.IOException: Write fault on path /var/lib/jenkins/jobs/pl-android/workspace/[Unknown]
at System.IO.FileStream.FlushBuffer (System.IO.Stream st) [0x0006b] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.IO/FileStream.cs:1040
at System.IO.FileStream.FlushBuffer () [0x00000] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.IO/FileStream.cs:1054
at System.IO.FileStream.Flush () [0x00020] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.IO/FileStream.cs:859
at System.IO.StreamWriter.Flush () [0x0002e] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.IO/StreamWriter.cs:191
at System.IO.StreamWriter.Dispose (Boolean disposing) [0x0001e] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.IO/StreamWriter.cs:162

And, as I write this, I notice the hidden line in there, which says:

System.IO.IOException: Write fault on path /var/lib/jenkins/jobs/pl-android/workspace/[Unknown]

Jumping on the box, and running mkdir for that path fixes it.
Maybe this erroneous error message could be fixed in an upcoming update, along with ETC? :smile: