简体   繁体   English

科尔多瓦:[错误:请安装Android目标:“android-21”

[英]Cordova : [Error: Please install Android target: “android-21”

I just updated cordova + ionic in my app, after that i installed successfully Android-SDK v22 via Android SDK manager. 我刚刚在我的应用程序中更新了cordova + ionic,之后我通过Android SDK管理器成功安装了Android-SDK v22。

But after the running command: 但是在运行命令之后:

cordova build android 

I always get the following message: 我总是收到以下消息:

Running command: /Users/peter/workspace/myapp/platforms/android/cordova/build 
[Error: Please install Android target: "android-21".

Hint: Open the SDK manager by running: /Users/peter/adt-bundle-mac/sdk/tools/android
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: /Users/peter/workspace/myapp/platforms/android/cordova/build: Command failed with exit code 2
You may not have the required environment or OS to build this project
Error: /Users/peter/workspace/myapp/platforms/android/cordova/build: Command failed with exit code 2
    at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:131:23)
    at ChildProcess.emit (events.js:110:17)
    at maybeClose (child_process.js:1008:16)
    at Process.ChildProcess._handle.onexit (child_process.js:1080:5)

I tried also 我也试过了

cordova platform rm android 
cordova platform add android 

But with the same result: 但结果相同:

I tried to find a few hours any working solution, but with luck. 我试着找几个小时的任何工作解决方案,但运气好。

Thanks for any advice. 谢谢你的建议。

System information: 系统信息:

OS: Mac OS X Yosemite
Node Version: v0.12.0
Cordova CLI: 4.3.0
Ionic Version: 0.9.27
Ionic CLI Version: 1.3.18
Xcode version: Xcode 6.2 Build version 6C131e 
ios-sim version: 3.1.1 
ios-deploy version: 1.4.0 

I just had the same problem. 我刚遇到同样的问题。 I had to change the target: 我不得不改变目标:

# Project target.
target=android-22

This should be done in two files: 这应该在两个文件中完成:

myApp /platforms/android/ project.properties myApp /platforms/android/CordovaLib/ project.properties myApp / platforms / android / project.properties myApp / platforms / android / CordovaLib / project.properties

Also the manifest should be updated: 清单应该更新:

<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="22" />

Follow these steps. 跟着这些步骤。
1) Type android on command line.(Make sure ANDROID_HOME and PATH are set properly) 1)在命令行上键入android 。(确保正确设置ANDROID_HOME和PATH)
2) Select API 21 from the populated list. 2)从填充的列表中选择API 21
3) Click install packages . 3)单击install packages
4) Type android avd on command line. 4)在命令行上键入android avd
5) Set API level and other config. 5)设置API级别和其他配置。
6) Now type ionic build android . 6)现在输入ionic build android

many times the problem is that not is configurated the path environment variable ANDRIOD_HOME. 很多时候问题是没有配置路径环境变量ANDRIOD_HOME。 Take a look 看一看

%ANDROID_HOME% = C:\Program Files (x86)\Android\android-sdk
In Path:
%ANDROID_HOME%\tools;
%ANDROID_HOME%\platform-tools;

In my case it was the path to my SDK folder that was causing this error. 在我的情况下,我的SDK文件夹的路径导致此错误。

C:\\Users\\username\\AppData\\Local\\Android\\android-sdk C:\\ Users \\用户名\\ AppData \\本地\\的Android \\ Android的SDK

changed to 变成

C:\\Users\\username\\AppData\\Local\\Android\\sdk C:\\ Users \\用户名\\ AppData \\本地\\的Android \\ SDK

I have been having the same problem in windows. 我在Windows中遇到了同样的问题。 It appeared that when I was running the SDK Manager you have to select "Run as Administrator" otherwise it denies permission to install certain files, on of them being "ANDROID-22" 看来,当我运行SDK Manager时,你必须选择“以管理员身份运行”,否则它拒绝安装某些文件的权限,其中“ANDROID-22”

Here is the the link I found to resolve this issue: android sdk manger not updating 这是我发现解决此问题的链接: android sdk manger没有更新

打开Android SDK Manager,检查目标版本是否存在,如果不存在则安装。

Make sure your project path doesn't consist spaces. 确保您的项目路径不包含空格。

I face the same problem asking me to install the target android platform when build. 我面临同样的问题,要求我在构建时安装目标android平台。 I have triple confirm my android sdk path, jdk path and various setting in path but still getting the same error. 我有三重确认我的Android sdk路径,jdk路径和路径中的各种设置,但仍然得到相同的错误。 Finally, the problem resolved by simply renamed(removed spaces) the folder that store my Cordova project. 最后,通过简单地重命名(删除空格)存储我的Cordova项目的文件夹来解决问题。 For example : "C:\\Cordova & Phonegap Sample\\MyCordovaApp" to "C:\\Cordova_Sample\\MyCordova". 例如:“C:\\ Cordova&Phonegap Sample \\ MyCordovaApp”到“C:\\ Cordova_Sample \\ MyCordova”。

另一种满足android目标要求的方法是:

$sdkmanager "platforms;android-21"

For those who run Visual Studio and have Mobile Development with JavaScript installed, you can run C:\\ProgramData\\Microsoft\\AndroidSDK\\25\\tools\\android.BAT and then proceed to install Android 5.0.1 or the relevant API. 对于那些运行Visual Studio并安装了JavaScript的移动开发的用户,可以运行C:\\ProgramData\\Microsoft\\AndroidSDK\\25\\tools\\android.BAT ,然后继续安装Android 5.0.1或相关API。

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM