简体   繁体   English

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

[英]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. 我一直在Visual Studio中使用Apache Cordova的工具模板来构建一个应用程序,它已经为我工作了两个月,这没问题,但是昨天在我将其构建为停止工作六次之后突然出现了。

In VS you get some really bad build errors that don't tell you much about the problem like: 在VS中,您会遇到一些非常糟糕的构建错误,这些错误并不能告诉您很多有关以下问题的信息:

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 严重性代码说明项目文件行源错误C:\\ Konstruktion \\ MyFirstApp \\ MyFirstApp \\ MyFirstApp \\ platforms \\ android \\ cordova \\ build.bat:命令失败,退出代码为1 MyFirstApp C:\\ Konstruktion \\ MyFirstApp \\ MyFirstApp \\ MyFirstApp \\ ERROR构建一个平台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 严重性代码说明项目文件行源错误C:\\ Konstruktion \\ MyFirstApp \\ MyFirstApp \\ MyFirstApp \\ platforms \\ android \\ cordova \\ build.bat:命令失败,退出代码为1 MyFirstApp C:\\ Konstruktion \\ MyFirstApp \\ MyFirstApp \\ MyFirstApp \\ MDAVSCLI 1生成

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: 因此,我确实尝试在没有Visual Studio的情况下仅使用CMD命令来构建它,这是我当时得到的错误:

[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). (这是手写的感觉,如果您知道我可以更新问题,我不知道如何从cmd复制到整个输出)。

Things I have tried so far 到目前为止我尝试过的事情

  1. re-install the asked tools and sdk platforms via SDK manager 通过SDK Manager重新安装要求的工具和SDK平台
  2. re-install the entire sdk 重新安装整个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) 在Windows-10上尝试一下(这样会有所帮助)

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! 这个问题仅影响用户如何在Visual Studio中使用Cordova工具! (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. 导航到debug文件夹并删除其内容,再次构建,它应该可以再次工作。

bin\Android\Debug

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

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