Search Unity

Question Installing Android SDK/NDK + OpenJDK without Unity Hub

Discussion in 'Android' started by Midiphony-panda, Mar 4, 2021.

  1. Midiphony-panda

    Midiphony-panda

    Joined:
    Feb 10, 2020
    Posts:
    243
    Hello !

    My question is in the title :D

    Basically, we would like to automatize the installation of Unity and every platform modules.
    This is useful for quickly setting up Unity for new users or on a build machine.

    Everything went fine until we tried to add the Android support, since the Android SDK/NDK + OpenJDK tools are not provided by the manuel setup executable. We would like to use the tools recommended by Unity, instead of manually installing the Android tools and selecting versions that might be not properly supported.

    I tried using Unity Hub to install the tools on an already installed editor, but no success (from Hub GUI and from CLI) :
    "Unity Hub.exe" -- --headless install-modules --version "2020.2.4f1" -m android-sdk-ndk-tools
    C:\Program Files\Unity Hub>
    Failed to execute the command due the following, please see '-- --headless help' for assistance.
    Error: This version of the Editor could not be found. Have you tried installing it using the hub?


    What would be the recommended way for this use case ?
    I see 3 solutions :

    1. Automatize everything with Unity Hub and Unity Hub CLI (I don't feel comfortable at all using it, it looks like it's not very reliable)
    2. Install the Android tools (+ Open JDK) manually (but now we have to know which versions to use : how to get this information reliably ?)
    3. Store on our NAS the Android tools installed on one computer by the Unity Hub, so our deploy scripts can copy-paste them for others

    Also, it would be welcome if anyone had some insights about using or not the Android tools given by Unity :)


    NB :
    (https://docs.unity3d.com/Manual/android-sdksetup.html)
    "Unity recommends that you use the Unity Hub to install Android SDK & NDK tools, to ensure that you receive the correct versions and configuration. Unity installs Android SDK & NDK Tools and OpenJDK respectively in the SDK, NDK and OpenJDK folders under /Unity/Hub/Editor/[EditorVersion]/Editor/Data/PlaybackEngines/AndroidPlayer/."
     
    dongch007 likes this.
  2. Midiphony-panda

    Midiphony-panda

    Joined:
    Feb 10, 2020
    Posts:
    243
  3. MauMatt

    MauMatt

    Joined:
    Feb 27, 2021
    Posts:
    3
    any news
     
  4. Slip_de_feu

    Slip_de_feu

    Joined:
    Jun 13, 2021
    Posts:
    8
    It works for me.

    If you are facing problems with Unity Hub about installing "Unity 2020.3.11f1 / Unity 2021.1.11f1 and android modules (SDK, NDK, OpenJDK)", here's my solution :

    1) Firstly, I would recommend to install "UnitySetup-Android-Support-for-Editor-2020.3.11f1.exe" to your Unity 2020.3.11f1's path or "UnitySetup-Android-Support-for-Editor-2021.1.11f1.exe" to your Unity 2021.1.11f1's path.
    You'll have a folder named "AndroidPlayer" in your path "{UNITY_PATH}\2020.3.11f1\Editor\Data\PlaybackEngines\" or "{UNITY_PATH}\2021.1.11f1\Editor\Data\PlaybackEngines\".

    2) In your "AndroidPlayer" folder, decompress these 3 7z files : "Android_NDK_19.0.5232133.7z", "OpenJDK_1.8.0_152.7z", "Android_SDK.7z"

    3) Run Unity 2020.3.11f1 / Unity 2021.1.11f1 and go to FILE > Build settings, click on "switch platform"

    4) You can now build your android apps in Unity 2020.3.11f1 / Unity 2021.1.11f1
     
  5. SteveK88

    SteveK88

    Joined:
    Apr 2, 2022
    Posts:
    1
    FARSDA likes this.
  6. HuishIT

    HuishIT

    Joined:
    Jun 9, 2022
    Posts:
    3
    We ran in to this recently.
    We deploy Unity Hub and Unity Editor via ConfigMgr as silent installs.
    We set the install directory for Unity Editor to the same directory that it would have installed to if you manually installed it via Unity Hub:
    'UnitySetup64-2022.1.21f1.exe' /S /D=C:\Program Files\Unity\Hub\Editor\2022.1.21f1


    If we run
    'C:\Program Files\Unity Hub\Unity Hub.exe' -- --headless editors -i
    it's listed:
    2022.1.21f1 , installed at C:\Program Files\Unity\Hub\Editor\2022.1.21f1\Editor\Unity.exe

    'C:\Program Files\Unity Hub\Unity Hub.exe' -- --headless install-modules --version 2022.1.21f1 -m android android-sdk-ndk-tools
    returns the following:

    Failed to execute the command due the following, please see '-- --headless help' for assistance.
    Error: No editor found for version "2022.1.21f1".

    Even tried the
    --changeset
    flag which had no luck.

    Seems to be a bug..
     
  7. villevli

    villevli

    Joined:
    Jan 19, 2016
    Posts:
    89
    The
    --changeset
    or
    -c
    parameter is required to install versions that are not latest. You can get the value for each editor version from https://unity.com/releases/editor/archive. It is the last part of the Unity Hub link for each version. e.g. unityhub://2022.2.19f1/765657fe9343 has
    765657fe9343
    . You can also get it from the
    ProjectSettings/ProjectVersion.txt
    file in an Unity project

    For example this would be a command to install the 2022.2.19f1 version of the editor and the modules required to make android builds:
    'C:\Program Files\Unity Hub\Unity Hub.exe' -- --headless install -v 2022.2.19f1 -c 765657fe9343 -m android android-sdk-ndk-tools android-open-jdk
     
    Last edited: May 16, 2023
  8. HuishIT

    HuishIT

    Joined:
    Jun 9, 2022
    Posts:
    3
    That's installing the editor with the modules, rather than installing the modules after the editor is already installed.

    ProjectSettings/ProjectVersion.txt
    shows the version as 2022.1.21f1 (9ac1ff5ca45b).

    Running the following command:
    'C:\Program Files\Unity Hub\Unity Hub.exe' -- --headless install-modules --version 2022.1.21f1 --changeset 9ac1ff5ca45b -m android android-sdk-ndk-tools android-open-jdk
    returns the following error:
    Failed to execute the command due the following, please see '-- --headless help' for assistance.
    Error: No editor found for version "2022.1.21f1".


    We might have to use your command instead as this doesn't work as intended.
     
  9. HuishIT

    HuishIT

    Joined:
    Jun 9, 2022
    Posts:
    3
    Ok, for those encountering the "No editor found for version" or "No modules found for this editor. Module installation is only supported for editors installed with Unity Hub" errors, I've gotten to the bottom of it.
    Basically, poor documentation and weird functionality. Unity will be updating the documentation soon.

    I logged a bug report with Unity describing the problem we have. So, it turns out, if you use the standalone Unity Editor installer, that's not been designed to work with the Unity Hub (including the headless commands and modules) which means you'd have to use the standalone installers for modules (including Android) if you wanted to install this silently, you can't use the Hub to install modules on the standalone Editor.

    So the 'correct' way is to do it all through the Hub. Use it to install Unity Editor as well as any modules and don't use the standalone installers. This way, the headless command will work.
    1. Install Unity Hub
      1. Download UnityHubSetup.exe from https://unity.com/download
      2. Install silently with:
        UnityHubSetup.exe /allusers /S
    2. Get available Unity Editor versions to install (via the Hub)
      "C:\Program Files\Unity Hub\Unity Hub.exe" -- --headless editors --releases

    3. Install Unity Editor (via the Hub)
      Pick a version and use that to install silently with:
      "C:\Program Files\Unity Hub\Unity Hub.exe" -- --headless install --version 2023.2.14f1
    4. Install Unity Editor Modules (via the Hub)
      Install modules silently with:
      "C:\Program Files\Unity Hub\Unity Hub.exe" -- --headless install-modules --version 2023.2.14f1 --module android android-sdk-ndk-tools android-open-jdk.-11.0.14.1+1
    They also advised me that the Android versioning for OpenJDK is not automated.
    When you try to install the module
    android-open-jdk
    you need to specify the exact version or you'll get a "No modules found to install". error.
    The recommended version is returned in the error message. E.g. “Did you mean: android-open-jdk-11.0.14.1+1”
    So instead of
    android-open-jdk
    , you will need something like:
    android-open-jdk-11.0.14.1+1
    .
     
    Last edited: Mar 19, 2024