简体   繁体   中英

Please install Android target: “android-21” but it is installed?

My problem

I have been using the Tools for Apache Cordova template in visual studio to build an app it has been working for me for like two months no problem at all but then suddenly yesterday after I built it like 6 times it just stopped working.

In VS you get some really bad build errors that don't tell you much about the problem like:

Severity Code Description Project File Line Source Error C:\\Konstruktion\\MyFirstApp\\MyFirstApp\\MyFirstApp\\platforms\\android\\cordova\\build.bat: Command failed with exit code 1 MyFirstApp C:\\Konstruktion\\MyFirstApp\\MyFirstApp\\MyFirstApp\\ERROR building one of the platforms 1 Build

and

Severity Code Description Project File Line Source Error C:\\Konstruktion\\MyFirstApp\\MyFirstApp\\MyFirstApp\\platforms\\android\\cordova\\build.bat: Command failed with exit code 1 MyFirstApp C:\\Konstruktion\\MyFirstApp\\MyFirstApp\\MyFirstApp\\MDAVSCLI 1 Build

So I did try to build it without the help of visual studio with just the CMD commands this was the error I then got:

[Error: Please install Android target: "android-21"]
Hint: Open the SDK manager by running C:\Users\username\AppData\Local\Anndroid\sdk\tools\android.BAT
You will require:
1. "SDK Platfrom" for android-21
2. "Android SDK Platform-tools (latest)
3. "Android SDK Build-tools (latest)]
Error: cmd: Command failed with exit code 2
at ChildProsses.whenDone (C:\Users\myUsername\AppData\Roming\npm\node_modules\cordova\node_modules\cordova-lib\src\cordova\superspawn.js:134:23)
at ChildProcess.emit (events.js:110:17)
at mybyClose (child_process.js:1015:16)
at Process.ChildProcess._handle.onexit (child_process.js:1087:5)

(This is handwritten sens I don't know how copy to the entire output from cmd if you know I can update the question).

Things I have tried so far

  1. re-install the asked tools and sdk platforms via SDK manager
  2. re-install the entire sdk
  3. this Stack Overflow question

What will I try today?

  1. The awesome solutions readers can come up with!
  2. Install everything on a different computer and try there
  3. Try it on windows-10 (like that will help)

Images

从SDK上说我已经安装了android-21

I found why the problem appears. This is a problem that only affects user how uses Cordova tools for Visual Studio! (I think).

If you start a build and then cancel it if you have device or emulator selected it will corrupt some files in the debug folder:

C:\Konstruktion\myApp\myApp\myApp\bin\Android\Debug

or where you have put it.

If you don't know where it is just right click the project name in the solution explorer and then click "Open path in File Explorer"

Navigate to the debug folder and delete it's contents, build again and it should work again.

bin\Android\Debug

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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