How to solve the compiling error: Please install Android target: "android-22" or any other android version when executing cordova run android command in node.js

Android error in cordova:  Please install Android target: "android-x"

When you get the mentioned fatal error "Please install Android target:"  running any compiling command of the cordova or ionic platform, for example :

ionic run android --device
#or
ionic run android --emulator
#or
cordova run android --device
#or 
cordova build android --release

You'll get that message, this happens because your machine doesn't have the appropriate SDK to build your application. To solve this problem open the SDKManager (located in the android sdk installation path [SDK Manager.exe]).

Image

Check that your targetSdkVersion of your project matches with one installed sdk on your machine (is recommendable to simply install the required sdk that the build requires and everything will work perfectly). Check what version you need in the android manifest, It is usually is located in yourprojectpath\platforms\android (or simply install the sdknumber that the message says).

<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="23" />

Note :

Even if you have targeted "16" (corresponding to android 4.1.2) , and the problem still without solution, simply restart the node.js console, open it and try again. If the problem persist and you have already installed your required sdk, restart your machine and this will be solved when you try again.


Senior Software Engineer at Software Medico. Interested in programming since he was 14 years old, Carlos is a self-taught programmer and founder and author of most of the articles at Our Code World.

Sponsors