简体   繁体   English

请安装Android目标:“android-21”

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

I have installed the latest cordova. 我已经安装了最新的cordova。 The version is 4.3.0. 版本是4.3.0。 I created an empty Cordova project: 我创建了一个空的Cordova项目:

cordova create test com.test Test

I then add the platform: 然后我添加平台:

cordova platform add android

I built the project with: 我用以下方法构建了项目:

cordova build android

But i always get: 但我总是得到:

[Error: Please install Android target: "android-21".

Hint: Open the SDK manager by running: C:\Program\ Files\     (x86)\Android\android-studio\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)]

So i ran "android" to confirm I have latest SDK installed: 所以我运行“android”来确认我安装了最新的SDK: 在此输入图像描述

I then tried changing the target android sdk to be 19 so in AndroidManifest.xml I changed: 然后我尝试将目标android sdk更改为19,所以在AndroidManifest.xml中我更改了:

<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="21" />

to: 至:

<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="19" />

I ran the build command again, and I still get the exact same error. 我再次运行构建命令,我仍然得到完全相同的错误。 This is driving me nuts. 这让我疯了。 Anyone have any ideas? 有人有主意吗? I've built many many cordova projects on this same PC and have never seen this problem before. 我在同一台PC上构建了许多cordova项目,之前从未见过这个问题。

I had the same problem and I fixed it appending to the PATH environment variable the following Android SDK folders: 我有同样的问题,我修复了它附加到PATH环境变量以下Android SDK文件夹:

  • C:\\Program Files\\Android\\sdk\\tools C:\\ Program Files \\ Android \\ sdk \\ tools
  • C:\\Program Files\\Android\\sdk\\platform-tools C:\\ Program Files \\ Android \\ sdk \\ platform-tools

not sure if this the place to post this answer but I spend over an hour trying to find why "cordova build" was demanding 22, when I had 23 installed so I thought I'd share: 不确定这是否是发布这个答案的地方,但我花了一个多小时试图找到为什么“cordova build”要求22,当我安装了23时所以我想我会分享:

In my case the project was created before I did and update was was targeting android-22 changing the line: "target=android-22" to "target=android-23" 在我的情况下,项目是在我做之前创建的,更新是针对android-22更改行: “target = android-22”“target = android-23”

in the following files allowed a build: \\platforms\\android\\project.properties \\platforms\\android\\CordovaLib\\project.properties 在以下文件中允许构建: \\ platforms \\ android \\ project.properties \\ platforms \\ android \\ CordovaLib \\ project.properties

I had the same problem - it occurs if you only download the Android SDK but have not yet started the android command and installed updates. 我有同样的问题 - 如果您只下载Android SDK但尚未启动android命令并安装更新,则会出现此问题。 In this case Cordova is telling you to install/update the SDK for Android's API version 23 (specified as "android-23" in your platforms/android/project.properties file). 在这种情况下,Cordova告诉您安装/更新Android的API版本23的SDK(在您的platforms/android/project.properties文件中指定为“android-23”)。

Solution: run android [*] and select the corresponding: 解决方案:运行android [*]并选择相应的:

  • Under Tools: 在工具下:
    • "Android SDK Platform-tools 23.1 “Android SDK平台工具23.1
    • "Android SDK Build-tools 23.1 “Android SDK Build-tools 23.1
  • Under Android 6.0 (API 23) 在Android 6.0下(API 23)
    • SDK Platform SDK平台

Install these and re-run cordova build android and it should work. 安装这些并重新运行cordova build android ,它应该工作。

[*] Assuming your sdk/tools path is on your system PATH (see here ) [*]假设你的sdk / tools路径在你的系统路径上(见这里

Well you need to update Android SDK tools and Android SDK platform-tools first. 那你需要先更新Android SDK工具和Android SDK平台工具。 Then you will get the update for API 21 然后,您将获得API 21的更新

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

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