首页 > 代码库 > Please install Android target

Please install Android target

今天在执行ionic build android时出现以下错误:
[Error: Please install Android target: "android-22".


Hint: Open the SDK manager by running: D:\Program\ Files\ (x86)\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


错误原因:工程属性配置文件中目标平台版本不一致。


解决方法:
1、确保系统已经安装了目标平台的API

技术分享

// 修改项目所在文件夹的以下3个文件,确保目标平台版本一致,如:
// # Project target.
// target=android-22
myApp/platforms/android/project.properties 
myApp/platforms/android/CordovaLib/project.properties
myApp/platforms/android/CordovaLib/AndroidManifest.xml


// AndroidManifest.xml文件修改如下
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="22" />

技术分享

Please install Android target