0

When I try to build the app using ionic build android I'm getting this error:

[Error: Please install Android target: "android-22".

Hint: Open the SDK manager by running: C:\Program\ Files\Android\android-sdk\tools\android.BAT
You will require:
1. "SDK Platform" for android-22
2. "Android SDK Platform-tools (latest)
3. "Android SDK Build-tools" (latest)]
ERROR building one of the platforms: Error: cmd: Command failed with exit code 2
You may not have the required environment or OS to build this project
Error: cmd: Command failed with exit code 2
    at ChildProcess.whenDone (C:\Users\nbk2cbg\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\cordova\superspawn.js:139:23)
    at ChildProcess.emit (events.js:110:17)
    at maybeClose (child_process.js:1015:16)
    at Process.ChildProcess._handle.onexit (child_process.js:1087:5)

I've installed Android API 23, 22 and 17. Added the PATH to the Environment Variables. Installed and reinstalled nodejs.

Obviously I also installed the platform-tools (all of them) and the Build-tools (all of them).

I forget to mention that my environment is on windows.

Any other idea?

2 Answers2

0

Try this solutions:

  1. you should first add android platform before building it.

    cordova platform add android

  2. try to append to the PATH environment variable the following Android SDK folders:

C:\Program Files\Android\sdk\tools

C:\Program Files\Android\sdk\platform-tools

  1. update Android SDK tools and Android SDK platform-tools first. Then you will get the update for API 21

Cheers bro ..

Nadeem Khoury
  • 886
  • 6
  • 18
0

Just remove the android platform and add 3.7.1

cordova platforms remove android
cordova platforms add android@3.7.1

After than

ionic build android

And you will find the .apk file at :

"C:\Development\test\platforms\android\ant-build\MainActivity-debug-unaligned.apk"

I had the exact same error as yours after that everything worked ! OS Windows 10 Source : https://stackoverflow.com/a/30029080/1106537

Community
  • 1
  • 1