I am trying to create a simple app through ionic framework. I have followed all the instructions given in the link http://ionicframework.com/getting-started/ and installed node.js, Ionic and Cordova frameworks, Apache Ant, Java SDK and Android ADK. Then I start an app, go to its folder, add android platform and build it. In the command ‘ionic build android’, it gives the below error:
[Error: Please install Android target: "android-21".
Hint: Open the SDK manager by running: C:\Users\Aparna\AppData\Local\Android\and
roid-sdk\tools\android.BAT
You will require:
1. "SDK Platform" for android-21
2. "Android SDK Platform-tools (latest)
3. "Android SDK Build-tools" (latest)]
ERROR building one of the platforms: Error: C:\Windows\System32\myApp\platforms\
android\cordova\build.bat: Command failed with exit code 2
You may not have the required environment or OS to build this project
Error: C:\Windows\System32\myApp\platforms\android\cordova\build.bat: Command failed with exit code 2
at ChildProcess.whenDone (C:\Users\Aparna\AppData\Roaming\npm\node_modules\c
ordova\node_modules\cordova-lib\src\cordova\superspawn.js:131: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 have verified that all the packages mentioned in the error are installed, and also updated the path variables correctly. However, I still keep getting the same error.
Can anyone suggest a solution/ workaround?
Thanks!
You can try building after closing all other applications except your terminal… Some times this problem occurs due to low memory availability required by Android build.
Please let me know if it solves ur problem.
I think you do not have latest android sdk : android-21 , you can update sdk using “Manage Sdk.exe” . In windows search "Manage Sdk: and then update your android sdk to latest.
@rajul885 I did check and all the packages for Android API 21 are installed. Also I have installed the latest Android SDK Platform-tools and Build-tools. Below is a screenshot for your reference:
Thanks @veshsare for the solution!
However, when I tried to update the AndroidManifest.xml and project.properties.xml, it gave me an access denied message and wouldn’t let me update. One of the reasons might be, I was running the command prompt as an Admin and so the project folder was getting created in C:\Windows\System32. And maybe that is why, ionic as well was not able to access the android libraries.
Finally, I deleted my project folder from System32 (which I was able to do somehow with admin permissions), and then opened up a user command prompt, and created the project in a folder on desktop.
I executed all the commands, and I was successfully able to build the app.