I am attempting to configure Google Play Game Services into my Android game but ever since I imported the plugin I haven’t been able to build an APK. I imagine I have misconfigured it…
The “Error: Could not find or load main class Files\Unity\Hub\Editor\2020.3.2f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\cmdline-tools\latest\bin\…” seems like it’s looking for half a file path? I’m guessing the space in “Program Files” is causing confusion.
Have I forgotton to comment out a path somewhere?
Or is a path misconfigured?
I have tried unticking/ticking the options under Preferences > External Tools. That allowed the build process to start but hung every time on my first scene.
I have updated to 2020.3.2f1.
Using the JDK/SDK from Unity.
I’ve tried setting the JAVA_HOME environment variable to point to the Unity OpenJDK folder as well as C:\Program Files\Java\jdk-15.0.1
I’ve also tried removing JAVA_HOME
I’ve tried adding a ‘/’ to the end of the paths in External Tools
I’m not sure what my next step should be, I’d appreciate any help.
Resolved by moving the Android SDK into a folder without spaces in it.
The SDK can’t handle “*\Program Files*”.
So I changed the location of the Unity editors in Unity Hub to install to C:\UnityEditors.
Wow. I remember when Microsoft first pulled that ridiculous “c:\Program Files” grade-A nonsense and here in 2021 it is still biting people
But is this really true?! Is it true in general of Unity on Windows? Or is it only true if you tell Unity to install the Android SDK and you happen to be under Windows?
Because if so, you really should file an official bug with Unity. There’s no way this is intentional and I bet 90% of Windows users with Unity would be unable to solve this issue on their own.
It does seem to be, which is a little mad that I didn’t see it come up in my searches across the Internet.
Android Studio’s SDK Manager is what flagged it up to me with the below warning (the file path is just for example):
I think a similar warning when installing Unity Hub would be useful as the default install folder is
C:\Program Files\Unity\Hub\Editor (https://docs.unity3d.com/Manual/GettingStartedInstallingHub.html). I will raise it with Unity, maybe they will point out that I blasted past their existing warnings.
Can’t believe it still goes wrong on 2021.3, but I’ve found a fix:
elevate any text editor as administrator
open sdkmanager.bat at “C:\Program Files\Unity\Editor\YOUR_VERSION*Editor\Data\PlaybackEngines\AndroidPlayer\SDK\cmdline-tools\latest\bin”*
find code here set DEFAULT_JVM_OPTS=-Dcom.android.sdklib.toolsdir=%~dp0\..
add " to %~dp0.. like below set DEFAULT_JVM_OPTS=-Dcom.android.sdklib.toolsdir="%~dp0\.."
back to Unity and try building again
(I ran into some other error with gradle after that, but at least sdkmanager.bat is happy…) EDIT: I’ve found my problem about gradle and it’s totally different. I’ve messed up my AndroidManifest and I’ve fixed it up:-)
Com’on guys it’s not the first year that “Program Files” exists. At least Unity Hub should show a notice about it, or even better, change its default folder.
Brother i am getting error with gradle after following this sdkmanager issue , i have been following lot of tutorials but i am unable solve the issue , it would be helpfull if someone respond and help me in solving my issue with gradle
It seems likely that the empty space in the folder name “UNITY VERSIONS” in (Mac) Applications/UNITY VERSIONS/2022.3.5f1 etc prevents an Android build from being possible. Any attempt to rename the folder UNITY_VERSION stops Unity from starting. How to fix?