Cordova: Android SDK not found. Make sure that it is installed. If it is not at the default location, set the ANDROID_HOME environment variable

后端 未结 8 629
太阳男子
太阳男子 2020-12-01 05:00

I am having problem to build android with Cordova, when I execute cordova build android, I receive this error:

Error: Android SDK not found. Ma         


        
相关标签:
8条回答
  • 2020-12-01 05:36

    Update to new Android package to solve the error -

    cordova platform remove android
    cordova platform add android
    cordova build android --release
    
    0 讨论(0)
  • 2020-12-01 05:36

    In My Case, This is a Scenario

    1.I have an SDK platforms tools Version 23

    2.I have added the Android Platform to My Cordova Project

    3.It works fines Until I update the SDK to 26

    4.After Updating the SDK it Throws the same Error

    Cordova: Android SDK not found. Make sure that it is installed. If it is not at the default location, set the ANDROID_HOME environment variable

    1. I just Resolved this by removing and Adding the Android platforms in my Project

      cordova platform remove android

      cordova platform add android

    2. Now it works fine :)

    0 讨论(0)
  • 2020-12-01 05:41

    @Rjak here is the manual for downgrading SDK version with valid links for older SDK versions. It works for me with same issue, after downgraded to tools v25.2.5 & platform-tools to v25.0.3 build successful

    0 讨论(0)
  • 2020-12-01 05:41

    As someone else stated, it is because of the android command being deprecated:

       C:\>android
       **************************************************************************
       The "android" command is deprecated.
       For manual SDK, AVD, and project management, please use Android Studio.
       For command-line tools, use tools\bin\sdkmanager.bat
       and tools\bin\avdmanager.bat
       **************************************************************************
    

    In my case, I managed to fix it changing the newer android.bat that is bundled in the sdk, in the "tools" folder.

    Just change this lines in the sdk/tools/android.bat:

    From this: (Line ~20)

    set avd_objects=;avd;target;device;

    To:

    set avd_objects=;avd;targets;device;

    From This: (Line ~37)

    echo android list target
    

    To:

    echo android list targets
    

    Explanation: The cordova build.bat will eventually call check_reqs.js script, and thats where this validation is done. If you look for the actual error text, it shows that the script is trying to call "android list targets --compact" command, which I assume was the older way to do it.

    0 讨论(0)
  • 2020-12-01 05:42

    I solved my question uninstalling Android Studio and install the CLI SDK Manager following this guide:

    https://guides.codepath.com/android/Installing-Android-SDK-Tools

    0 讨论(0)
  • 2020-12-01 05:51

    TL;DR In some cases, even if you have successfully added android sdk to your path the problem still persists, the reason is related to your Android tools/ folder version, currently the android command is not supported anymore but it is still required by the command ionic cordova build android, then you should download an old one.

    Now that you know where the problem is, let's get into the solution:

    1. Download an old sdk tools version according to your platform Mac, Windows, Linux.
    2. Replace the current tools/ folder in /Users/username/Library/Android/sdk on Mac or C:\Users\[account]\AppData\Local\Android\sdk on Windows or ~/Android/Sdk on Linux by the downloaded tools/ folder.
    3. Restart your command-line and be happy!
    0 讨论(0)
提交回复
热议问题