Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Bug Unity Hub CLI does not install Android JDK

Discussion in 'Unity Hub' started by Carlos9x, Dec 18, 2022.

  1. Carlos9x

    Carlos9x

    Joined:
    Aug 5, 2017
    Posts:
    12
    I've been trying to build my Android game in a CI environment using GameCI and Unity 2022.2.1f1. However, when attempting to make the build, I end up hitting this error:
    Any ideas on how to resolve this? Appreciate any guidance I can get on this!
     
    achimmihca likes this.
  2. chunhui_beanterra

    chunhui_beanterra

    Joined:
    Nov 7, 2022
    Posts:
    1
  3. Andrew010110

    Andrew010110

    Joined:
    Oct 8, 2022
    Posts:
    18
    I've reported this as a bug (IN-21006 and IN-25628) for months now and have had no response on their end.
     
  4. achimmihca

    achimmihca

    Joined:
    Feb 13, 2016
    Posts:
    266
  5. slembcke2

    slembcke2

    Joined:
    Jun 26, 2013
    Posts:
    270
    Augh. I've spent all day dealing with this as well trying to set up a headless Linux build. I used the installers you can get from the download archive here: https://unity.com/releases/editor/archive

    It does create a Data/PlaybackEngines/AndroidPlayer directory in the player install, but it doesn't contain the Android tools or NDK. On closer inspection of the install logs I found that it's trying to install the Mac version of the Android build tools:
    Downloading Unity 2021.3.22f1
    Finished downloading 'https://download.unity3d.com/download_unity/b6c551784ba3/LinuxEditorInstaller/Unity.tar.xz' to '/tmp/Unity.tar.xz'
    Downloading Android Build Support
    Finished downloading 'https://download.unity3d.com/downlo...up-Android-Support-for-Editor-2021.3.22f1.pkg' to '/tmp/UnitySetup-Android-Support-for-Editor-2021.3.22f1.pkg'​

    The installer really isn't special, it just downloads tar files and unpacks them, and they are listed here for the LTS versions: https://unity.com/releases/editor/qa/lts-releases Unfortunately every single one of them has the same Linux -> Mac error in the URL for the Android build tools, and if you try and follow the obvious naming pattern for the rest of the linux packages, then file doesn't exist on the server. :( This error seems to go back several years in the LTS versions.

    Last time I set up the editor on desktop Linux using Hub, I had the exact same issue. The player folder was there, but missing the JDK, NDK, etc. I installed them myself, set the paths in the GUI and that worked fine. I tried doing that here too, but you must set those paths in the GUI which is not possible. I can't even figure out where it stores the settings file has those paths in it to copy a working config from another machine. Completely frustrated and stuck.

    We did try using Unity Cloud build as well, but it's 10x slower than building locally on our own (rather outdated) computers. Even if we considered that useful for just CI, the CPU costs alone would be several hundred dollars a month for a 5 person team.
     
  6. Andrew010110

    Andrew010110

    Joined:
    Oct 8, 2022
    Posts:
    18
    Hub 3.4.2 beta just released which supposedly fixes the headless install issues though I haven’t gotten a chance to try it yet.
     
  7. slembcke2

    slembcke2

    Joined:
    Jun 26, 2013
    Posts:
    270
    Could you elaborate? Are there instructions somewhere? I did try installing Hub in my container at some point, but it wouldn't launch. Not even with just a --version or --help argument. I wasn't too surprised since it's all Electron now right? Can that even work headlessly?

    Though to be clear, does this new version of Hub _actually_ install a working Android build component for Linux? In my post above I found that not only are all the various install methods installing the Mac version, but that the Linux one doesn't even seem to exist for any LTS of Unity going back several years.

    As for the issue of installing your own JDK, SDK, NDK, etc. I did figure out there is a second prefs file at ~/.local/share/unity3d/prefs. It's just an XML file, but all the string values are base64 encoded.

    You have to tell it to ignore the embedded paths, base64 encode your actual paths, and then paste those in. You'll need to install openJDK 8, and get the "command line tools" package from the Android dev downloads to get sdkmanager to then download the Android dependencies.
    <pref name="JdkUseEmbedded" type="int">0</pref>
    <pref name="SdkUseEmbedded" type="int">0</pref>
    <pref name="NdkUseEmbedded" type="int">0</pref>
    <pref name="JdkPath" type="string">cGF0aC9nb2VzL2hlcmUK=</pref>
    <pref name="AndroidSdkRoot" type="string">cGF0aC9nb2VzL2hlcmUK</pref>
    <pref name="AndroidNdkRootR21D" type="string">cGF0aC9nb2VzL2hlcmUK</pref>

    I think that would have made my build work. Unity reconized and accepted it all, though our build was still failing due to some VR plugin we used in. I threw in the towel at that point, so I'm not sure if it _actually_ resolved the ability to make Android builds headlessly.
     
    Last edited: Apr 5, 2023