Ionic builing error

I am trying to build hybrid app with ionic and cordova at first i run below commands and they run successfully but after running the last command i get this error

ionic start firtApp
cd firtApp
ionic platform add android

note: it return me android-21 error, and i changed the android-21 to android-18, and it runs successfully

ionic build android

after running the above command i got this error

BUILD FAILED D:\New folder\android-sdk-final\android-sdk-fully\sdk\tools\ant\build.xml:601: T he following error occurred while executing this line: D:\New folder\android-sdk-final\android-sdk-fully\sdk\tools\ant\build.xml:542: U nable to resolve project target ‘android-21’ Total time: 1 second C:\Users\Mohammad\firstapp\platforms\android\cordova\node_modules\q\q.js:126 throw e; ^ Error code 1 for command: cmd with args: /s /c “ant debug -f C:\Users\Mohammad\f irstapp\platforms\android\build.xml -Dout.dir=ant-build -Dgen.absolute.dir=ant-g en” ERROR building one of the platforms: Error: C:\Users\Mohammad\firstapp\platforms \android\cordova\build.bat: Command failed with exit code 8 You may not have the required environment or OS to build this project Error: C:\Users\Mohammad\firstapp\platforms\android\cordova\build.bat: Command f ailed with exit code 8 at ChildProcess.whenDone (C:\Users\Mohammad\AppData\Roaming\npm\node_modules \cordova\node_modules\cordova-lib\src\cordova\superspawn.js:131:23) at ChildProcess.emit (events.js:98:17) at maybeClose (child_process.js:756:16) at Process.ChildProcess._handle.onexit (child_process.js:823:5)

please help me with this error
i really like to bulid hybrid apps with my web knowledge

Suggest running Android SDK Manager and checking that android-21 (i.e. Lollipop) has been installed and all updates are installed.

Remember to run SDK Manager multiple times (i.e. run, install/update, quit, run, etc) until it doesn’t have anything left to install.

1 Like