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. JustAnotherDude

    JustAnotherDude

    Joined:
    Oct 28, 2013
    Posts:
    279
    Failed to update Android SDK package list error when using SDK installed with unity.


    Code (CSharp):
    1. CommandInvokationFailure: Failed to update Android SDK package list.
    2. F:/Programs/Unity/2019.2.0f1/Editor/Data/PlaybackEngines/AndroidPlayer\SDK\tools\bin\sdkmanager.bat --list
    3.  
    4. stderr[
    5. Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
    6.     at com.android.repository.api.SchemaModule$SchemaModuleVersion.<init>(SchemaModule.java:156)
    7.     at com.android.repository.api.SchemaModule.<init>(SchemaModule.java:75)
    8.     at com.android.sdklib.repository.AndroidSdkHandler.<clinit>(AndroidSdkHandler.java:81)
    9.     at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:73)
    10.     at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:48)
    11. Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema
    12.     at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
    13.     at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    14.     at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    15.     ... 5 more
    16. ]
    17. stdout[
    18.  
    19. ]
    20. exit code: 1
    21. UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <8277255796414cc8b8865316c1676de5>:0)
    22. UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <8277255796414cc8b8865316c1676de5>:0)
    23. UnityEditor.Android.SDKManager.UpdatePackagesList () (at <8277255796414cc8b8865316c1676de5>:0)
    24. UnityEditor.Android.SDKManager.ListAvailable (UnityEditor.Android.SDKManager+Component type) (at <8277255796414cc8b8865316c1676de5>:0)
    25. UnityEditor.Android.PlayerSettingsEditorExtension.<StartGettingReleasedAPILevels>m__0 () (at <8277255796414cc8b8865316c1676de5>:0)
    26. System.Threading.ThreadHelper.ThreadStart_Context (System.Object state) (at <a8ed250850854b439cedc18931a314fe>:0)
    27. System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) (at <a8ed250850854b439cedc18931a314fe>:0)
    28. System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) (at <a8ed250850854b439cedc18931a314fe>:0)
    29. System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state) (at <a8ed250850854b439cedc18931a314fe>:0)
    30. System.Threading.ThreadHelper.ThreadStart () (at <a8ed250850854b439cedc18931a314fe>:0)
    31. UnityEngine.UnhandledExceptionHandler:<RegisterUECatcher>m__0(Object, UnhandledExceptionEventArgs)
    Unity 2019.2.0f1 and Hub 2.0.4.



    Edit: Nevermind, fixed by removing my other java install from java home and path.
     
    Last edited: Aug 7, 2019
  2. simaggin

    simaggin

    Joined:
    Nov 8, 2015
    Posts:
    2
    Good day.
    I faced the same problem.
    Did you manage to find a solution?
     
    Kaweri likes this.
  3. JustAnotherDude

    JustAnotherDude

    Joined:
    Oct 28, 2013
    Posts:
    279
    Yeah, as I said in the OP, I removed java_home and the java path from my environment variables, (just deleted them, I did not add a new one).
     
    ADNOC_LNG and Amet like this.
  4. mikito-yoshiya

    mikito-yoshiya

    Joined:
    Nov 3, 2014
    Posts:
    3
    You may need to install Java8. The Android SDK refers to the system's JDK ...
    Perhaps the currently installed JDK is 11 or 12, so it is quick to remove it.
    However, to install Oracle Java8, you need to register an account, and using Open JDK may be easier.

    https://azul.com/downloads/zulu/

    I really want to use the JDK bundled with Unity. Is there a good way?
     
  5. JustAnotherDude

    JustAnotherDude

    Joined:
    Oct 28, 2013
    Posts:
    279
    Yes.
     
    adjust-sdk likes this.
  6. bibbis

    bibbis

    Joined:
    Dec 5, 2016
    Posts:
    58
    Hi,
    What does it mean to remove java_home and the java path from environment variables?
     
  7. adrianjwoods

    adrianjwoods

    Joined:
    May 7, 2020
    Posts:
    1
    Same. Some articles say remove environment variables.. some say add them... working with unity and mobile is just always a nightmare.
     
  8. JustAnotherDude

    JustAnotherDude

    Joined:
    Oct 28, 2013
    Posts:
    279
    On Windows, java uses an environment variable, one named JAVA_HOME and it also might use the Path variable to find the java binaries.

    https://docs.oracle.com/en/database...tml#GUID-DD6F9982-60D5-48F6-8270-A27EC53807D0

    New Unity comes bundled with Java so it shouldn't need any external java "stuff".
    Removing them should fix any java issues, as long as you choose to install and use the bundled java.

    However there is another bug on unity that leaves some path bars inverted and apparently this bugs the java usage.

    https://forum.unity.com/threads/java-9-jdk-9-support-by-unity-android.499354/page-3#post-5724547

    So I now just use a script to fix this stuff automatically...


    Code (CSharp):
    1. string newJDKPath = EditorApplication.applicationPath.Replace("Unity.exe", "Data/PlaybackEngines/AndroidPlayer/OpenJDK");
    2.  
    3.         if (Environment.GetEnvironmentVariable("JAVA_HOME") != newJDKPath)
    4.         {
    5.             Environment.SetEnvironmentVariable("JAVA_HOME", newJDKPath);
    6.         }
    Put in on a static constructor on a class marked with [InitializeOnLoad] on the Editor folder of your project.
     
    PixelFireXY, TorLinn, agnis16 and 9 others like this.
  9. Yerbol05

    Yerbol05

    Joined:
    Apr 24, 2020
    Posts:
    3
  10. burakekincioglu

    burakekincioglu

    Joined:
    May 8, 2020
    Posts:
    3
    Hey everybody, i have the same error on my windows10, and installed android studio latest version, I set android studio SDK path to unity android sdk path, and it is solved.
     
    Lesh48 likes this.
  11. rowen_felton

    rowen_felton

    Joined:
    Apr 22, 2020
    Posts:
    2
    Hi, I had the same problem and solved it as follows: 1. I uninstalled my previous version of Java. 2. Installed Java 8
    (Java SE Development Kit 8u251). 3. Copied the path to my environment settings in Settings/Environment settings. Moved it up in the hierarchy 4. Also added JAVA_HOME path to the environment settings. 5, IMPORTANT Went to Unity: Edit/Preferences/External Tools.
    6. Here I unticked the following boxes under ANDROID: (a) JDK installed with Unity (Recommended) and browsed to where Java is stored (C:\Program Files\Java\jdk1.8.0_251) (b) Did the same with SDK. 7. MAGIC!
     
  12. Wekthor

    Wekthor

    Joined:
    Apr 30, 2011
    Posts:
    164
    I had same issue on Mac after previously making build without an issue. I uninstalled current Unity version ( 2019.3.4 ) through Unity Hub and installed new version ( 2019.3.14 ). If you have same issue, try to reinstall Unity version.
     
    Janesmishra likes this.
  13. chris_unity559

    chris_unity559

    Joined:
    Mar 26, 2019
    Posts:
    12
    We are using Unity 2019.3.12f1 and I'm getting this same issue on a Mac. We can't update our project yet at the moment to a newer version of Unity. Does Unity have an official workaround for this? Is it actually fixed in a newer version of Unity?
    Thanks.
     
  14. Leofaber

    Leofaber

    Joined:
    May 28, 2020
    Posts:
    1
    Hey, I had the same issue on Ubuntu18.04. Yesterday I was able to build the Android apk but today I was not able anymore.
    I fixed it exporting the JAVA_HOME environment variable (pointing to Unity Java SDK installation) and appending the Java executable to the PATH environment variable:

    Code (JavaScript):
    1. export JAVA_HOME=/home/leofaber/Softwares/unity/editors/2019.3.14f1/Editor/Data/PlaybackEngines/AndroidPlayer/OpenJDK
    2. export PATH=$JAVA_HOME/bin:$PATH
     
    Walya96, dan_ginovker and br-anderson like this.
  15. Hassan-Kanso

    Hassan-Kanso

    Joined:
    Jun 10, 2014
    Posts:
    11
    fixed by unchecking all checboxes bellow and check them again
    P.S : you find it in unity under Edit -> Preferences -> External Tools
    androidsdk.PNG
     
  16. clamum

    clamum

    Joined:
    May 14, 2017
    Posts:
    61
    I had this problem too, seemingly out of nowhere. My Android game compiled one night and the next it didn't. I did enable the keystore for it, maybe that caused it?

    But I uninstalled Java (I had v13 I believe) and re-installed JDK v8. I also added the JAVA_HOME environment variable since it wasn't there (following Yerbol05's link above) after installation. I then went into Unity -> Edit -> Preferences -> External Tools, unchecked the Unity Open JDK, and specified the Java installation directory (C:\Program Files\Java\jdk1.8.0_251).

    My game then compiled. I was thinking it was due to some Android SDK issue, cause of the error message, but it seems to have been Java (for whatever reason).
     
    RoryBuckley and bangaenski like this.
  17. KRAKENSAGA

    KRAKENSAGA

    Joined:
    Jun 18, 2020
    Posts:
    1
    can you upload video? because i have the same problem but I don't understand
     
  18. pouyan4938

    pouyan4938

    Joined:
    Jul 5, 2018
    Posts:
    3
    Hi. i had same problem and i solved.
    i remove my JAVA_HOME variable but it doesn't change any thing.
    i have unity 2019.4(lts) and java 8 and updated SDK and i added java_home in my variables. i download a another version of JDK and SDK and put them in unity! and i try to build, and my error fixed. now i back my jdk and sdk and try to build again and its work!
     
    asd2222fg likes this.
  19. danilocjr

    danilocjr

    Joined:
    Oct 4, 2017
    Posts:
    8
    This is the one!! Simple as can be...
     
  20. cristianlazo5

    cristianlazo5

    Joined:
    May 18, 2020
    Posts:
    1
    Thank you, It works for me on MacOS 10.15.5 (19F101) Unity 2019.3.14f1
     
    Last edited: Jul 18, 2020
  21. Clrchan

    Clrchan

    Joined:
    Nov 9, 2019
    Posts:
    2

    Thank you so much, It works for me Unity 2019.4.5f1

     
    BonusB likes this.
  22. Enumerator_T

    Enumerator_T

    Joined:
    Nov 5, 2014
    Posts:
    16
    Had both problems, Java, home variables, path variables, untick box's and retick, ALL WORKED but, now it's not fixing it with anything that i do of the above, This seems to be some sort of stupid unity issue and not java..
     
    Cuicui_Studios likes this.
  23. Enumerator_T

    Enumerator_T

    Joined:
    Nov 5, 2014
    Posts:
    16
    Ok so I just found out what's happening, Unity seems to be ignoring the last "/", edit the JDK location string add / at the end of it.
    So now it looks like
    C:/Program Files/Unity/Editor/2019.4.4f1/Editor/Data/PlaybackEngines/AndroidPlayer/OpenJDK/
     
  24. Radegast

    Radegast

    Joined:
    Dec 2, 2016
    Posts:
    3
    Oh my gosh...
     
  25. nedhaljalali

    nedhaljalali

    Joined:
    Sep 14, 2017
    Posts:
    13
    cool working now ty .
     
    Clevereen likes this.
  26. Brexterity3

    Brexterity3

    Joined:
    May 30, 2020
    Posts:
    1
    I can't believe this was the problem I've been having. Thank you!
     
  27. Clevereen

    Clevereen

    Joined:
    Apr 22, 2018
    Posts:
    8
    worked for me as well
     
  28. Clevereen

    Clevereen

    Joined:
    Apr 22, 2018
    Posts:
    8
    It seems that Enumerator_T was completely right! I was fed up by unchecking and checking! This perfectly worked!
     
  29. mksindia

    mksindia

    Joined:
    Nov 3, 2017
    Posts:
    5
    Worked for me
     
  30. piggie_pie

    piggie_pie

    Joined:
    May 18, 2015
    Posts:
    4
    I am having the same issue... This solution did NOT work for me even though it has worked in the past. Using 2019.4.9
     
    BonusB likes this.
  31. jgmakes

    jgmakes

    Joined:
    Jan 10, 2019
    Posts:
    75
    This seems to have fixed it. For me the problem arose when switching from iOS to Android after having added 2 new (Firebase) packages to the project.

    If this resetting is the issue, it seems that whatever trigger it flips should be done automatically when switching between platforms.
     
  32. cftcimert

    cftcimert

    Joined:
    Apr 4, 2018
    Posts:
    14
    Remove tick and select again.
     

    Attached Files:

  33. guilhermeribeiro9856

    guilhermeribeiro9856

    Joined:
    Jun 21, 2020
    Posts:
    1
    this worked for me! thanks
     
  34. uc9115

    uc9115

    Joined:
    Mar 4, 2020
    Posts:
    1
    Worked for me, Thanks!
     
  35. mrboembastic

    mrboembastic

    Joined:
    Oct 31, 2014
    Posts:
    14
    This worked for me thanks you.
     
  36. Ragavendran

    Ragavendran

    Joined:
    Nov 24, 2017
    Posts:
    5


    It's worked for me.. Thank you...
     
  37. battman00

    battman00

    Joined:
    Mar 28, 2020
    Posts:
    10
    Updating the $JAVA_HOME env variable fixed it for me.

    Instructions for MacOS:

    NOTE: replace `2019.4.13f1` with your version of Unity.

    1. Add the following lines to `~/.bash_profile`
    export JAVA_HOME=/Applications/2019.4.13f1/PlaybackEngines/AndroidPlayer/OpenJDK
    export PATH=$PATH:$JAVA_HOME

    2. Uncheck then recheck all the boxes under `Edit -> Preferences -> External Tools`
     
    theancientchild likes this.
  38. babayandbabay

    babayandbabay

    Joined:
    Aug 2, 2016
    Posts:
    2
    Thanks, it's worked for me!
     
  39. battman00

    battman00

    Joined:
    Mar 28, 2020
    Posts:
    10
    Awesome! I've spent hours troubleshooting this, so I'm glad it helped :)
     
  40. Conferno

    Conferno

    Joined:
    Feb 27, 2014
    Posts:
    49
    This helps me. I've just uncheck boxes and has add "/" at the end of the lines.
    I've spent a week trying to compile my project and has an Android SDK package list error.
    Unity team, damn, are you kidding us ?

    upload_2020-11-17_13-52-29.png
     
  41. bz_apps

    bz_apps

    Joined:
    Aug 19, 2014
    Posts:
    70
    Same, adding "/" to the end of the JDK path on mac fixed the issue for me.
     
  42. Ritik1999

    Ritik1999

    Joined:
    Jan 8, 2019
    Posts:
    2
    Noice Man It Worked Thanks
     
  43. MFKJ

    MFKJ

    Joined:
    May 13, 2015
    Posts:
    264
    My solution (2-minutes guide) to this problem, hope that it will be helpful.
     
    Last edited: Jan 1, 2021
  44. polyphonic13

    polyphonic13

    Joined:
    Apr 2, 2013
    Posts:
    17
    Thank you so much! You just saved me hours of time trying to debug this. "Turn it off and turn it on again" works again!
     
  45. Bersaelor

    Bersaelor

    Joined:
    Oct 8, 2016
    Posts:
    111
    The problem is, I have been seeing the bug described above for a few weeks now, and it reappears every time I open the project. So I have to uncheck, wait for resolver to fill, recheck, wait for resolver to fill every time I restart my mac (and open the project again). Same procedure as in above video, just on a daily basis.
    There is clearly an issue in `Unity/Hub/Editor/2020.2.0f1/PlaybackEngines/AndroidPlayer/SDK/tools/bin/sdkmanager` that should be fixed by Unity.
     
    Last edited: Dec 29, 2020
    Cuicui_Studios likes this.
  46. MFKJ

    MFKJ

    Joined:
    May 13, 2015
    Posts:
    264
    I agree with you. Same happening with me. Please unity check this issue
     
    Bersaelor likes this.
  47. br-anderson

    br-anderson

    Joined:
    Oct 2, 2019
    Posts:
    3
    This seriously helped me so much. I'm on macOS Catalina 10.15.7, using Unity 2019.2.7f2, and was having the same 'failed to update Android SDK' issues, after trying multiple things including downloading another version of Java, NDK, and a fresh uninstall/ reinstall of Unity through the Hub.

    Opened the .profile file ('cmd + shift + .' from personal User directory to view hidden files) in Visual Studio Code, and added those lines for the JAVA_HOME. Obviously I had to change the root path for the Mac, but instead of going from 'AndroidPlayer/OpenJDK' I had to go from 'AndroidPlayer/Tools/OpenJDK/MacOS'.

    Once I saved that, I wend to Unity>Preferences>ExternalTools, unchecked all the Android check boxes, clicked browse for every one that asked for it, then checked all the check boxes again.

    Finally built after days of pixelated android tears...
     
  48. ArshakKroyan

    ArshakKroyan

    Joined:
    Mar 4, 2015
    Posts:
    32
    Thank you, this really helped. :D
     
  49. Bersaelor

    Bersaelor

    Joined:
    Oct 8, 2016
    Posts:
    111
    I tried that too, it still didn't work. I still have to go to `Edit -> Preferences -> External Tools` and uncheck/recheck the checkmarks every time I open the project. This is a really annoying bug, please Unity Team, look into this problem.
     
    CareyMcDuff and krisventure like this.
  50. ahmedaniss

    ahmedaniss

    Joined:
    Sep 18, 2019
    Posts:
    98
    Problem fixed here :
     
    Last edited: Jun 7, 2021