When I run ionic build android command in root of ionic project, I am getting this error:
FAILURE: Build failed with an exception.
FOR WINDOW: I have faced this type of issue. But after exploring it solved in my case. I am using window 10. just follow few steps below:
download Android SKD Manager for windows. https://developer.android.com/studio at the end of this page. It is zip file. after extracting it will show tools directory.
Go to drive C:\ create new folder 'android-sdk'. copy tools folder and past in
C:\android-sdk
open command prompt as Administrator. Go to cd " c:\android-sdk\tools\bin ". sdkmanager will be show here. type skdmanager, it will show like this [=======================================] 100% Computing updates...
after that type "sdkmanager platform-tools" it will create platform-tools directory in C:\android-sdk
Now set System environment variables: right click on PC select properties. system settings will popup. click on > Environment Variables. Environment Variables will popup.
At this window System variables as like this. C:\android-sdk\platform-tools and C:\android-sdk\tools\bin
run command to build tools sdkmanager "build-tools;27.0.3"
Also make sure java path is defined. I hope it will solve problem.