Search Unity

Failed to update Android SDK package list error when using SDK installed with unity.

Discussion in 'Unity Hub' started by JustAnotherDude, Aug 5, 2019.

  1. iTouchi

    iTouchi

    Joined:
    Feb 20, 2020
    Posts:
    3
    Checking Unchecking didn't help.
    Removing environment variables didn't help.
    But adding the "/" did help.

    Thank you!
     
    PNUMIA-Rob likes this.
  2. enhawk

    enhawk

    Joined:
    Aug 22, 2013
    Posts:
    833
    I just did this on OSX and now it works. I hope someone at Unity is listening.
     
  3. sfilo

    sfilo

    Joined:
    Oct 23, 2012
    Posts:
    30
    I got the same error on MacOS using Unity 2019.4.18.f1 and after a lot of messing around I think I might have figured it out.

    At times ( don't know why ) Unity ( or something else ) starts resetting the JAVA_HOME environment variable to string empty when you start Unity. So even if you set JAVA_HOME via console or .bashrc/.zshrc depending on MacOS version it still doesn't work.

    I think that adding "/" to the external tools SDK path just forces Unity to set the path again which makes it work for a while. And after that if it stops working you can just remove the "/" save the path and it will work again for some time.

    What permanently fixed it for me was the post from using JustAnotherDude's suggestion and adding an editor script to the Editor folder that changes the JAVA_HOME environment variable every time Unity starts so there are no more surprises.

    Here's my version for MacOS

    Code (CSharp):
    1. using UnityEditor;
    2. using System;
    3.  
    4. public class UnityJavaSDKFIx : MonoBehaviour
    5. {
    6.  
    7.     [InitializeOnLoadMethod]
    8.     static void SetJavaHome()
    9.     {
    10.  
    11.         Debug.Log("JAVA_HOME in editor was: " + Environment.GetEnvironmentVariable("JAVA_HOME"));
    12.  
    13.         string newJDKPath = EditorApplication.applicationPath.Replace("Unity.app", "PlaybackEngines/AndroidPlayer/OpenJDK");
    14.  
    15.         if (Environment.GetEnvironmentVariable("JAVA_HOME") != newJDKPath)
    16.         {
    17.             Environment.SetEnvironmentVariable("JAVA_HOME", newJDKPath);
    18.         }
    19.  
    20.         Debug.Log("JAVA_HOME in editor set to: " + Environment.GetEnvironmentVariable("JAVA_HOME"));
    21.  
    22.     }
    23. }
     
    Last edited: Jan 27, 2021
  4. concubicycle

    concubicycle

    Joined:
    Jan 18, 2015
    Posts:
    4
    What the F***... This works. Unity....
     
  5. alfiesoromon

    alfiesoromon

    Joined:
    Oct 16, 2018
    Posts:
    1
    This fixed my problem. How can Unity be so ignorant of this kinda issue on mac?
     
    zzzzzxxxxxccccc likes this.
  6. sfilo

    sfilo

    Joined:
    Oct 23, 2012
    Posts:
    30
    I don't think it's the "/", I think adding the slash just forces Unity to update the path. You might run into this problem again later and removing the slash will fix it ( it happened for me ).
     
    ritesh_khokhani likes this.
  7. labshekh

    labshekh

    Joined:
    May 12, 2019
    Posts:
    1
    I just solved the issues by changing the API Compatibility Level from .NET Standard 2.0 to .NET 4.x.

    It worked for me
     
  8. kenanimohamed

    kenanimohamed

    Joined:
    Jan 19, 2021
    Posts:
    7
    hi this a simple and shor video that show what to do in a minute
     
  9. EKO_LX

    EKO_LX

    Joined:
    Dec 25, 2020
    Posts:
    45
    I had save issue on Mac.
    What I did is first removed java, which I installed separately from oracle site.
    Then set JAVA_HOME to PlaybackEngines/AndroidPlayer/OpenJDK folder from code
    Code (CSharp):
    1.     static void SetJavaHome()
    2.     {
    3.         //Debug.Log(EditorApplication.applicationPath);
    4.  
    5.         Debug.Log("JAVA_HOME in editor was: " + Environment.GetEnvironmentVariable("JAVA_HOME"));
    6.  
    7.         string newJDKPath = EditorApplication.applicationPath.Replace("Unity.app", "PlaybackEngines/AndroidPlayer/OpenJDK");
    8.  
    9.         if (Environment.GetEnvironmentVariable("JAVA_HOME") != newJDKPath)
    10.         {
    11.             Environment.SetEnvironmentVariable("JAVA_HOME", newJDKPath);
    12.         }
    13.  
    14.         Debug.Log("JAVA_HOME in editor set to: " + Environment.GetEnvironmentVariable("JAVA_HOME"));
    15.     }
    as suggested here: https://stackoverflow.com/questions...te-android-sdk-package-list-unity-2019-2-10f1

    That fixed my issue.
     
  10. th3z0d1ac

    th3z0d1ac

    Joined:
    May 14, 2014
    Posts:
    15
    Thanks, works
     
  11. Hassan-Kanso

    Hassan-Kanso

    Joined:
    Jun 10, 2014
    Posts:
    11
    Glad it helped so many people! it's a nightmare having your plan hanging because of a minor issue...
     
  12. cmersereau

    cmersereau

    Joined:
    Nov 6, 2020
    Posts:
    52
    Don't think I saw this solution here, but it worked for me. Apparently a problem arises if your editor files are inside "C:\Program Files\..." on a windows machine. The space in "Program Files" messes everything up once certain plugins need to access the tools there. Moving it to a different directory may fix it for you.

    Resolved - Failed to update Android SDK package list - Unity Forum
     
  13. ritesh_khokhani

    ritesh_khokhani

    Joined:
    Jun 26, 2013
    Posts:
    47
    TODAY,

    Just disabling Android SDK checkbox and adding '/' at the end of sdk path fixes the problem for me. ;)
     
  14. ritesh_khokhani

    ritesh_khokhani

    Joined:
    Jun 26, 2013
    Posts:
    47

    After struggling with issue for 2 days and applying different solutions (which also works few hours) came to know that,
    above one is the main cause of error.
    Use of editor script works perfect for me. Thanks for saving time.
     
  15. Kazoos

    Kazoos

    Joined:
    Nov 28, 2012
    Posts:
    19
    This is still a problem in 2020.3.3 quite shocking really.
     
    Cuicui_Studios likes this.
  16. p0w1nd

    p0w1nd

    Joined:
    Oct 28, 2015
    Posts:
    140
    Wow. This is just unbelievable!! This solution really works! Thanks a lot.

    FYI;
    I'm using Unity 2020.3.19f (macOS), Firebase, Google External Dependency 1.2.166.
    When clicking "Force Resolve" I got this error:

    Trying stuff like setting JAVA_HOME and java in PATH doesn't help. But unchecking and checking again those sections related to Java path in Unity External Tools preferences does solve the problem!


    Edit 1: It stops working again. Hmmm.... :|

    Edit 2: On my machine (macOS), I install OpenJDK via Homebrew, then no more "unable to locate java runtime" error when running "Force Resolve".

     
    Last edited: Oct 3, 2021
  17. xnguyenvyx

    xnguyenvyx

    Joined:
    Jul 20, 2016
    Posts:
    4
    this works for me too. haha. I think this is engine bugs.
     
  18. aromana

    aromana

    Joined:
    Nov 11, 2018
    Posts:
    137
    This problem still occurs on Unity 2021.2, and the "uncheck and recheck the java checkboxes" thing still fixes it. Hard to believe. Is there a bug tracking this issue?
     
  19. umarhyatt

    umarhyatt

    Joined:
    Nov 20, 2020
    Posts:
    6
    when i build my android project then Daemon error occurred , help me. I use playfab, mopab and Facebook SDK in my project
     

    Attached Files:

  20. zzzzzxxxxxccccc

    zzzzzxxxxxccccc

    Joined:
    Dec 4, 2021
    Posts:
    1
    same but JDK! MacOS Catalina
     
  21. krupasknr

    krupasknr

    Joined:
    Feb 27, 2019
    Posts:
    6
  22. rabea_abuhaltam

    rabea_abuhaltam

    Joined:
    Mar 10, 2017
    Posts:
    12
    I had the same error (unity Failed to update Android SDK package list)
    Solved by clicking the play button. Then >> File >> Player sittings >> it will automatically update the list then select the latest API >> click the play button again then the problem is solved forever :)
     
  23. muneebhassan

    muneebhassan

    Joined:
    Dec 13, 2021
    Posts:
    1
    Thank you so much, It works for me Unity 2019.4.33f1
     
  24. skhan2523

    skhan2523

    Joined:
    May 26, 2016
    Posts:
    16
    using the Open JDK that comes with Unity I was unable to force resolve the android dependencies.
     
  25. jamalh

    jamalh

    Joined:
    Feb 27, 2019
    Posts:
    1
    Thanks a lot sir! Acutally worked :D
     
  26. Apollych

    Apollych

    Joined:
    Oct 7, 2019
    Posts:
    8
    Same for me. Thank u! (Unity 2020, Mac)
     
  27. mfatihbarut

    mfatihbarut

    Joined:
    Apr 11, 2018
    Posts:
    1,059
    thank you very much
     
  28. basriozturk

    basriozturk

    Joined:
    Dec 18, 2018
    Posts:
    1
    this solution worked for me in case anyone still having the same issue
     
  29. yamoinca

    yamoinca

    Joined:
    Jun 1, 2013
    Posts:
    7
    Just came by to say using Unity 2020.3.24f1 on Mac OS Big Sur 11.6.5 I got hit by this (previously was able to build), and the trailing "/" appears to be the solution for me.

    The only thing I'd add/ask is how did you figure this out?!
     
    LT23Live likes this.
  30. LT23Live

    LT23Live

    Joined:
    Jul 8, 2014
    Posts:
    97
    The fact that this is still a problem for unity is surprising. Especially because we know they comb these forums rigorously.
     
  31. userq

    userq

    Joined:
    Jun 4, 2017
    Posts:
    40
    I am really sorry to tell this, but the fixes/solutions described here are not really fixes. Just workarounds - sometimes it doesn't even work this workaround with the checkboxes (it's ridiculus what one has to do, just to get the android sdk working).

    Real fix needs to come from Unity.

    Anyways... what worked lately for me (before was just unchecking the boxes, restart and check again). Now I unchecked the JDK and added a "\" symbol at the end. Then from the dependency manager -> force resolve. It worked. :confused:
     
    Last edited: May 19, 2022
  32. siddharth3322

    siddharth3322

    Joined:
    Nov 29, 2013
    Posts:
    1,049
    These two steps helped me to run my project on MacOS and export Android build:
    external tools edited.png
     
    damelin likes this.
  33. milox777

    milox777

    Joined:
    Sep 23, 2012
    Posts:
    195
    Still happening on 2020.3.35 LTS.
     
  34. siddharth3322

    siddharth3322

    Joined:
    Nov 29, 2013
    Posts:
    1,049
    I have upgraded my project to Unity 2021.3.3f1 LTS version then after above settings worked for me and now I have open and closed Unity hundred times after this and it was working proper and I can export Android build.
     
  35. Flarup

    Flarup

    Joined:
    Jan 7, 2010
    Posts:
    164
    Can Unity PLEAAAEEAASE fix this! While some of the above workarounds does work, you have to redo them every time you open your Unity Editor. SO annoying :( :(
     
    siddharth3322 likes this.
  36. siddharth3322

    siddharth3322

    Joined:
    Nov 29, 2013
    Posts:
    1,049
    yes - we have to do every time and this is annoying too.
    may be in the next release of Unity, this thing will get fixed.
     
  37. amiga4ever

    amiga4ever

    Joined:
    Apr 27, 2020
    Posts:
    6
    That solve the issue! THANKS
     
  38. yuvzohar

    yuvzohar

    Joined:
    Mar 15, 2018
    Posts:
    1

    Thanks!
     
  39. Drumstig

    Drumstig

    Joined:
    Oct 28, 2017
    Posts:
    2
    nhannguyendev0 likes this.
  40. Jarkko129

    Jarkko129

    Joined:
    Nov 15, 2019
    Posts:
    2
    This helped me, but i didn't re-install or added JAVA_HOME env variable.
    Steps:
    1. Uncheck Preferences -> External Tools -> JDK Installed with Unity
    2. Replace with C:\Program Files\Java\jdk[whateverversion]
    3. Try to build (build fails and throws some error)
    4. Check Preferences -> External Tools -> JDK Installed with Unity
    5. Now the path should be Unity's own again
    6. Build will work now
     
  41. Sixbreaker

    Sixbreaker

    Joined:
    Dec 29, 2016
    Posts:
    11
    this worked for me lmao this is crazy
     
  42. Arthur-LVGameDev

    Arthur-LVGameDev

    Joined:
    Mar 14, 2016
    Posts:
    228
    I believe there's still a bug here on (latest) macOS (Intel build of 2022.2.11f1) -- possibly only occurs when the path contains a space.

    In my case, Unity installs are on RAID'd drive that's mounted at:
    /Volumes/Working Data/....


    The paths are correct but the error persists; if I run the commands just as they're spit out in the console errors, they fail (due to space), but if I escape them properly they work fine (and the Android SDK, etc. is all there/located as expected).
     
  43. ahmedaniss

    ahmedaniss

    Joined:
    Sep 18, 2019
    Posts:
    98
    problem fixed here :
     
  44. Arthur-LVGameDev

    Arthur-LVGameDev

    Joined:
    Mar 14, 2016
    Posts:
    228
    I can actually confirm, for certain, that there is still a bug related to this issue -- but it appears to be a macOS-specific issue, and only occurs when the path name contains a SPACE.

    My Unity editors are installed onto a volume that is mounted to
    /Volumes/Main Data/UnityEditors/**
    -- as long as that space exists, there's nothing you can do (I tried a multitude of things) that will get the Unity build process to work with the path, which appears to not properly escape the space.

    Attempting to manually escape the path does not appear to resolve the issue -- the input (path) is probably getting sanitized, essentially un-escaping the path in this scenario.

    Copying the
    AndroidPlayer/**
    contents to
    ~/Desktop/AndroidPlayer/**
    and then setting the paths appropriately (to reference that location, which has no spaces) in the Unity preferences DOES resolve the issue.

    I'm relatively confident that there IS a Unity-side bug related to having spaces in the path.

    That said, even Android Studio warns "spaces in the path may cause issues" when you open it; and you do need to open Android Studio to set it to reference the new paths & to download the appropriate SDK versions (at least if you're exporting the Android project, which I was).
     
    Last edited: Mar 21, 2023
    HelenL likes this.
  45. Mohanad_GX

    Mohanad_GX

    Joined:
    Mar 10, 2020
    Posts:
    13
    I have the same issue on 2022.14 I tried everything but nothing worked for me...

    It's building on 2020 without any problem but when I upgraded to 2022 I got this annoying issue :(
    Is there any other solutions ?
     
    xaldin-76 and Sakurako121 like this.
  46. abdullahNA

    abdullahNA

    Joined:
    Mar 13, 2022
    Posts:
    4
    My Unity Hub is in C Drive but my Unity Editor is in another drive
    in my case a solution for me is
    1) goto Edit>Preferences
    upload_2023-6-5_12-15-27.png
    .
    2) uncheck all the check boxes and check them again. Copy the address of JDK
    upload_2023-6-5_12-16-18.png
    .
    3) after copy the address uncheck the JDK check box and paste the copied address here manually
    upload_2023-6-5_12-19-18.png
    .
    4) force resolve the android dependency
    upload_2023-6-5_12-21-40.png
     
    Marrt likes this.
  47. Mzaid123

    Mzaid123

    Joined:
    Mar 29, 2022
    Posts:
    1
    Works for me Thanks :)
     
  48. Joyixir-dev

    Joyixir-dev

    Joined:
    Jul 27, 2022
    Posts:
    3
    I had this problem in macOS even after trying all the solutions.
    The problem solver for me was going to my SDK path, then cmdline-tools/xx.xx/bin and right click on "sdkmanager" and clicking open, to permit it to run.
    After that, the error disappeared.
     
  49. FeastSC2

    FeastSC2

    Joined:
    Sep 30, 2016
    Posts:
    978
    I had the problem too on a new computer. None of the solutions proposed worked.
    I ended up copying the AndroidPlayer folder from my other computer onto the new one.
    As I tried to do that, it couldn't copy over all the files because the file paths were too long.
    So I used the command line to copy it over using robocopy.
    Then finally it worked.

    This was all on Unity 2021.3.31.