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
Update to new Android package to solve the error -
cordova platform remove android
cordova platform add android
cordova build android --release
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
I just Resolved this by removing and Adding the Android platforms in my Project
cordova platform remove android
cordova platform add android
Now it works fine :)
@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
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.
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
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:
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.