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 661
太阳男子
太阳男子 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: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.

提交回复
热议问题