当我尝试使用ionic build android
构建应用时,我收到此错误:
[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)
我安装了Android API 23,22和17.为环境变量添加了PATH。已安装并重新安装的nodejs。
显然我还安装了平台工具(所有这些)和Build-tools(所有这些)。
我忘了提到我的环境是在Windows上。
还有其他想法吗?
答案 0 :(得分:0)
尝试此解决方案:
你应该在构建它之前首先添加android平台。
cordova平台添加android
尝试将以下Android SDK文件夹附加到PATH环境变量:
C:\ Program Files \ Android \ sdk \ tools
C:\ Program Files \ Android \ sdk \ platform-tools
干杯兄弟。
答案 1 :(得分:0)
删除android平台并添加3.7.1
cordova platforms remove android
cordova platforms add android@3.7.1
之后
ionic build android
您将在以下位置找到.apk文件:
"C:\Development\test\platforms\android\ant-build\MainActivity-debug-unaligned.apk"
在一切正常后,我和你的错误完全相同! 操作系统Windows 10 资料来源:https://stackoverflow.com/a/30029080/1106537