Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Resolved Failed to update Android SDK package list

Discussion in 'Editor & General Support' started by mraltair, Apr 2, 2021.

  1. mraltair

    mraltair

    Joined:
    Jul 23, 2014
    Posts:
    3
    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...

    I get the below error:
    upload_2021-4-2_11-42-49.png
    Then 4 errors in the console:
    upload_2021-4-2_11-43-10.png
    upload_2021-4-2_11-43-22.png
    upload_2021-4-2_11-43-33.png
    upload_2021-4-2_11-43-50.png

    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.
     
    fbdamon and jermesa_studio like this.
  2. mraltair

    mraltair

    Joined:
    Jul 23, 2014
    Posts:
    3
    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.

    I'm sure this was advised to me already.
     
  3. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    39,006
    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.
     
  4. mraltair

    mraltair

    Joined:
    Jul 23, 2014
    Posts:
    3
    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):

    upload_2021-4-3_8-20-16.png

    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. :D
     
  5. psioniccat

    psioniccat

    Joined:
    Jul 12, 2018
    Posts:
    2
    Can't believe it still goes wrong on 2021.3, but I've found a fix:

    1. elevate any text editor as administrator
    2. open sdkmanager.bat at "C:\Program Files\Unity\Editor\YOUR_VERSION\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\cmdline-tools\latest\bin"
    3. 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\.."


    4. 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.
     
    Last edited: Feb 27, 2024
  6. msbalfe

    msbalfe

    Joined:
    Apr 12, 2016
    Posts:
    2

    Yes! Thank you! Fixed it. You are my new best friend!
    This worked perfectly for me.
     
  7. budistudios

    budistudios

    Joined:
    Jan 24, 2024
    Posts:
    1
    set DEFAULT_JVM_OPTS=-Dcom.android.sdklib.toolsdir="%~dp0\.."


    It work 100%
     
  8. Devil_Inside

    Devil_Inside

    Joined:
    Nov 19, 2012
    Posts:
    1,120
    Thanks for the tip!
    This situation is ridiculous...
     
  9. Tonicat

    Tonicat

    Joined:
    Jul 27, 2018
    Posts:
    1
    you're my new best friend too!
     
  10. jermesa_studio

    jermesa_studio

    Joined:
    Apr 29, 2017
    Posts:
    8
    Thank you so much for this help in resolving the issue while working on my commercial projects.
     
  11. GOKULAVELAN

    GOKULAVELAN

    Joined:
    Aug 11, 2021
    Posts:
    3
    Thanks for the help.
    It worked great
     
  12. alfaleustechnologies

    alfaleustechnologies

    Joined:
    May 3, 2024
    Posts:
    1
    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
     

    Attached Files: