Google Play Games Services makes impossible to Build

Hello everyone,

I added Google Play Game Services to my project, and since then I am unable to Build the project for my device. It instantly produces an error, which I could not resolve.

It says:

ERROR: JAVA_HOME is set to an invalid directory: X:\Program Files\Unity\Hub\Editor\2019.3.0f5\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK\bin

UnityEditor.EditorApplication:Internal_CallGlobalEventHandler()

Please set the JAVA_HOME variable in your environment to match the location of your Java installation.

UnityEditor.EditorApplication:Internal_CallGlobalEventHandler()


.....

I have JDK 11 installed, but in the Preferences I am using Unity’s installed JDK. How comes, that Unity is trying to use my JAVA_HOME Jdk instead?

I also found out, that the GPGS is creating this error. By removing the package building works again. Installing it again breaks the Build Process.

Fixed it myself. I installed Games Services some weeks ago, uninstalled it and reinstalled it. This was the problem. I just checked out from an previous git branch, when GPGS was not installed and merged it into the current.