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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Command line build not working for Oculus Go Project because it can't find Android SDK

Discussion in 'Editor & General Support' started by devedse, Sep 19, 2019.

  1. devedse

    devedse

    Joined:
    Jan 2, 2017
    Posts:
    10
    Hi all,

    I'm currently working on automating the build pipeline for an Oculus Go project. (I'm not using the Unity build services).

    I'm making use of the Azure Devops Unity Build extension that executes a headless build of my Unity project for android:



    When I build this project using the tasks it fails after a while. When I open the project using the Unity Editor it will actually build an APK.

    I then compared the Editor.log output for the Azure DevOps build and the Editor.log for the manual build. These are the differences:

    Azure DevOps build (Editor.log):
    Code (CSharp):
    1. Script Compilation Pipeline Post Process Assets time: 0.000030s
    2. Assembly Updater Post Process Assets time: 0.000142s
    3. Refreshing native plugins compatible for Editor in 1.59 ms, found 12 plugins.
    4. Preloading 3 native plugins for Editor in 0.37 ms.
    5. Android PostProcess task "Checking prerequisites" took 28.95 ms
    6. Android PostProcess task "Detect Java Development Kit (JDK)" took 7.4023 ms
    7. AndroidSDKTools:
    8.  
    9.     root          : C:\Users\digitalstudio\AppData\Local\Android\sdk
    10.     tools         : C:\Users\digitalstudio\AppData\Local\Android\sdk\tools
    11.     platform-tools: C:\Users\digitalstudio\AppData\Local\Android\sdk\platform-tools
    12.     build-tools   : C:\Users\digitalstudio\AppData\Local\Android\sdk\build-tools\29.0.2
    13.  
    14.     adb      : C:\Users\digitalstudio\AppData\Local\Android\sdk\platform-tools\adb.exe
    15.     aapt     : C:\Users\digitalstudio\AppData\Local\Android\sdk\build-tools\29.0.2\aapt.exe
    16.     zipalign : C:\Users\digitalstudio\AppData\Local\Android\sdk\build-tools\29.0.2\zipalign.exe
    17.  
    18. AndroidJavaTools:
    19.     java     : C:\Program Files\Unity\Hub\Editor\2018.4.9f1\Editor\Data\PlaybackEngines\AndroidPlayer/Tools\OpenJDK\Windows\bin\java.exe
    20.     heapsize : 4096
    21.  
    22. Android PostProcess task "Detecting Android SDK" took 15893.1644 ms
    23. Android PostProcess task "Detect Android NDK" took 0.1456 ms
    24. Android PostProcess task "Trying to find a suitable Android device" took 5.7896 ms
    25. BuildPlayer: start building target 13
    26. - Starting compile Library/ScriptAssemblies/Unity.TextMeshPro.dll
    27. - Starting compile Library/ScriptAssemblies/Oculus.VR.dll
    28. - Finished compile Library/ScriptAssemblies/Oculus.VR.dll
    Manual Build using Unity (Editor.log):
    Code (CSharp):
    1. Script Compilation Pipeline Post Process Assets time: 0.000014s
    2. Assembly Updater Post Process Assets time: 0.000153s
    3. Refreshing native plugins compatible for Editor in 1.33 ms, found 12 plugins.
    4. Preloading 3 native plugins for Editor in 0.34 ms.
    5. DisplayProgressbar: Checking prerequisites
    6. Android PostProcess task "Checking prerequisites" took 17.4157 ms
    7. DisplayProgressbar: Detect Java Development Kit (JDK)
    8. Android PostProcess task "Detect Java Development Kit (JDK)" took 702.5003 ms
    9. DisplayProgressbar: Detecting Android SDK
    10. Uploading Crash Report
    11. UnityException: Android SDK not found
    12. Unable to locate Android SDK.
    13.  
    14. UnityEditor.BuildPipeline:BuildPlayerInternalNoCheck(String[], String, String, BuildTargetGroup, BuildTarget, BuildOptions, Boolean)
    15. UnityEditor.BuildPipeline:BuildPlayerInternal(String[], String, String, BuildTargetGroup, BuildTarget, BuildOptions) (at C:\buildslave\unity\build\Editor\Mono\BuildPipeline.bindings.cs:358)
    16. UnityEditor.BuildPipeline:BuildPlayer(String[], String, String, BuildTargetGroup, BuildTarget, BuildOptions) (at C:\buildslave\unity\build\Editor\Mono\BuildPipeline.bindings.cs:257)
    17. UnityEditor.BuildPipeline:BuildPlayer(BuildPlayerOptions) (at C:\buildslave\unity\build\Editor\Mono\BuildPipeline.bindings.cs:240)
    18. AzureDevOps:PerformBuild() (at Assets\Editor\AzureDevOps.cs:40)
    19. (Filename: Assets/Editor/AzureDevOps.cs Line: 40)
    20.  
    21. Unloading 78 Unused Serialized files (Serialized files now loaded: 0)
    22. System memory in use before: 74.7 MB.
    23. System memory in use after: 74.8 MB.
    So basically the 'command line' build isn't able to find the Android SDK. I did configure this in the UI though.

    Does anyone have an idea if it's possible to either fix this issue or be able to automatically provide the Android SDK location to the Unity build process?
     
  2. mahewitt

    mahewitt

    Joined:
    Mar 19, 2014
    Posts:
    279
    Did you ever find a fix for this @devedse ? Struggling with the same on anything pre. 2019
     
  3. chrisbrasington

    chrisbrasington

    Joined:
    Jul 14, 2021
    Posts:
    2
    Old thread, but I'll answer anyway since I encountered this.

    Set the environment variable of ANDROID_SDK_ROOT to your root directory (in the original example - C:\Users\digitalstudio\AppData\Local\Android\sdk) and do this with a pipeline variable.

    For me for some reason a manual run would detect the SDK just fine, but a pipeline task would say invalid path unless this env var was set.