Unity: Build failure, unable to update the SDK

21,513

Solution 1

Try installing Android SDK into some folder that does not require administrator priviledges to access (something like C:\SDKs\android-sdk). It worked for me.

Solution 2

I had a similar issue trying to update my android sdk and fixed it by running the sdk manager manually. In my Unity Editor console it printed out a long license agreement along with errors telling me what to do.

Firstly, if it does not exist, create an empty repositories.cfg file in your .android folder. For me that file is located at C:\Users\myuser\.android

Next, run the sdkmanager.bat like this in command prompt (your results and path may vary depending on your Unity version).

"C:\Program Files\Unity\Hub\Editor\2019.2.13f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\tools\bin\sdkmanager.bat"  "platforms;android-29"

I was then able to press y and accept the license.

Solution 3

What worked for me was to locate the "sdkmanager.bat" folder, start the command prompt with admin rights from there, and enter the following command:

.\sdkmanager "platform-tools" "platforms;android-29"

Solution 4

4 I face the same issue trying to update my android SDK and Try to build with both JAVA SDK tool this resolve my Issue (check ref Img)

Android build fails [2019.3.6f1]: Unable to update the SDK

CommandInvokationFailure: Unable to update the SDK. Please run the SDK Manager manually to make sure you have the latest set of tools and the required platforms installed. /Users/yogesh/Library/android-sdk/tempToolsDir\bin\sdkmanager.bat --sdk_root=/Users/yogesh/Library/Android/sdk tools platform-tools "build-tools;28.0.3"

Solution 5

I ran into this problem, and fixed it by defining the 'JAVA_HOME' environment variable, which was required for Unity's sdkmanager.bat to run. After this, Unity was able to seamlessly install from within Unity as intended.

Share:
21,513
Dokme
Author by

Dokme

Updated on January 05, 2021

Comments

  • Dokme
    Dokme over 3 years

    Unity Latest update 2018.3
    SDK Tools and Platforms up to date according to SDK Manager.
    Trying to build and run Android Build Settings.

    After updating the SDK, Unity still asks me to update the SDK by pressing a button built into the software. After I do this it tells me:

    Unable to update the SDK. Please run the SDK Manager manually to make sure you have the latest set of tools and the required platforms installed. See console log for details.

    When I take a look at the console, it tells me:

    CommandInvokationFailure: Unable to update the SDK. Please run the SDK Manager manually to make sure you have the latest set of tools and the required platforms installed. 
    C:\Program Files (x86)\Android\android-sdk\tempToolsDir\bin\sdkmanager.bat --sdk_root=C:\Program Files (x86)\Android\android-sdk tools platform-tools "build-tools;28.0.3"
    
    stderr[
    Error: Failed to find package Files
    Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
    ]
    stdout[
    
    ]
    exit code: 1
    UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <e1c3953b4cf040ddb1400046b1c34897>:0)
    UnityEditor.Android.Command.RunWithStdin (System.Diagnostics.ProcessStartInfo psi, System.String errorMsg, System.Collections.Generic.IEnumerable`1[T] input) (at <e1c3953b4cf040ddb1400046b1c34897>:0)
    UnityEditor.Android.AndroidSDKTools.RunAndroidSdkTool (System.String toolName, System.String arguments, System.Boolean updateCommand, System.String errorMsg, System.String toolsDir) (at <e1c3953b4cf040ddb1400046b1c34897>:0)
    UnityEditor.Android.AndroidSDKTools.UpdateSDK (UnityEditor.Android.AndroidJavaTools javaTools) (at <e1c3953b4cf040ddb1400046b1c34897>:0)
    UnityEditor.Android.PostProcessor.Tasks.CheckAndroidSDK+SDKComponentDetector.Update (UnityEditor.Android.AndroidSDKTools sdkTools, UnityEditor.Android.AndroidJavaTools javaTools, System.Version minVersion, UnityEditor.Android.PostProcessor.ProgressHandler onProgress) (at <e1c3953b4cf040ddb1400046b1c34897>:0)
    UnityEditor.Android.PostProcessor.Tasks.CheckAndroidSDK.EnsureSDKComponentVersion (UnityEditor.Android.AndroidJavaTools javaTools, System.Version minVersion, UnityEditor.Android.PostProcessor.Tasks.CheckAndroidSDK+SDKComponentDetector detector) (at <e1c3953b4cf040ddb1400046b1c34897>:0)
    UnityEditor.Android.PostProcessor.Tasks.CheckAndroidSDK.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <e1c3953b4cf040ddb1400046b1c34897>:0)
    UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <e1c3953b4cf040ddb1400046b1c34897>:0)
    UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
    

    I have updated the SDK manually, it also gave me an error there. I fixed it doing this trick:
    Can't update \tools - Android SDK Command Line Tools for Windows

    Anyway, I ran Unity with administrator, I ran the cmd with administrator for the manual updates and yet it still wont build. Help needed, thanks.

    SCREENSHOT: Unity SDK Update for Android build

  • Dokme
    Dokme over 5 years
    I have done this aswell. I have an android-sdk folder in my C: and updated the SDK there with cmd sdkmanager.bat --update. Right now I have used that folder instead of the Program Files (x86) folder for SDK External Tools in Unity and now it works. Yet it wont run and build without an android device connected to the computer.