When I run ionic build android command in root of ionic project, I am getting this error:
FAILURE: Build failed with an exception.
2018
The "android" command is deprecated.
try
sdkmanager "build-tools;27.0.3"
This work for me, as #Fadhil said
as the error says 'No installed build tools found' it means that
1 : It really really really did not found build tools
2 : To make him find build tools you need to define these paths correctly
PATH IS SAME FOR UBUNTU(.bashrc) AND MAC(.bash_profile)
export ANDROID_HOME=/Users/vijay/Software/android-sdk-macosx
export PATH=${PATH}:/Users/vijay/Software/android-sdk-macosx/tools
export PATH=${PATH}:/Users/vijay/Software/android-sdk-macosx/platform-tools
3 : IMPORTANT IMPORTANT as soon as you set environmental variables you need to reload evnironmental variables.
//For ubuntu
$source .bashrc
//For macos
$source .bash_profile
4 : Then check in terminal
$printenv ANDROID_HOME
$printenv PATH
Note : if you did not find your changes in printenv then restart the pc and try again printenv PATH, printenv ANDROID_HOME .There is also command to reload environmental variables .
4 : then open terminal and write HALF TEXT '$and' and hit tab. On hitting tab you should see full '$android' name.this verifys all paths are correct
5 : write $android in terminal and hit enter
I know this doesn't look related, especially given the error message, but I fixed this by installing a newer version of the Android SDK Build tools.
For me, the problem was that ANDROID_HOME was pointing to an old Android SDK path. After installing Android Studio, I had to update ~/.bash_profile accordingly for MAC (El Capitan)
export ANDROID_HOME="/Users/corneliusparkin/Library/Android/sdk"
Remember to re-start terminal or run this command after updating ~/.bash_profile
source ~/.bash_profile
I fix this by downloading sdk package called platform-tools and buid-tools using sdkmanager
. You can use sdkmanager.exe or if you are using SDK CLI, go to ~\AppData\Local\Android\sdk\tools\bin
and run this command:
sdkmanager "platform-tools" "platforms;android-26"
or
sdkmanager "build-tools;27.0.3"
or both
After that you should be able to run ionic cordova run android
or ionic build android
.
Note: globalize sdkmanager
command by adding ~\AppData\Local\Android\sdk\tools
and ~\AppData\Local\Android\sdk\tools\bin
to your environment variable.
Open Command Prompt Check for ANDROID_HOME path using SET ANDROID_HOME, if not set then set using below command.
SET ANDROID_HOME="C:\Users\VenkateshMogili\AppData\Local\Android\Sdk"
OR open system environment variables and create new variable as
Variable Name: ANDROID_HOME
Variable Value: C:\Users\VenkateshMogili\AppData\Local\Android\Sdk
and open cordova.gradle file (/platforms/android/CordovaLib/cordova.gradle) and search for getAndroidSdkDir() method and Replace the ANDROID_HOME path ("C:/Users/VenkateshMogili/AppData/Local/Android/Sdk") instead of System.getenv("ANDROID_HOME")
If license problem arises then type below command by opening the command prompt in C:\Users\VenkateshMogili\AppData\Local\Android\Sdk\tools\bin
sdkmanager "build-tools;27.0.3" //<-that will create build-tools folder and licenses folder.
It works for me.