[英]Getting Build Error Creating Android Application using Xamarin Extension for Visual Studio 2015 Preview
I'm using recently released Visual Studio 2015 Preview along with Xamarian Studio 5.6.3(or 5.6.2) extension for Visual studio. 我正在使用最近发布的Visual Studio 2015 Preview以及Visual Studio的Xamarian Studio 5.6.3(或5.6.2)扩展。
After Hours of downloading and installing all required software (all done successfully), I started developing Android Application in VS2015P, but every time I create blank Android application, I get this error, with no error code: 下载并安装所有必需的软件(所有成功完成)后,我开始在VS2015P中开发Android应用程序,但每次创建空白的Android应用程序时,我都会收到此错误,没有错误代码:
The "MergeApkRecipelists" task was not given a value for the required parameter "RecipeFiles". “MergeApkRecipelists”任务未获得所需参数“RecipeFiles”的值。
Figured this out by looking at Xamarin's .targets files. 通过查看Xamarin的.targets文件来计算出来。
Short Version 精简版
You can either: 你可以:
or 要么
Import
element defined in %PROGRAMFILES(x86)%\\MSBuild\\Xamarin\\Android\\Xamarin.Android.Common.After.targets. 注释掉%PROGRAMFILES(x86)%\\ MSBuild \\ Xamarin \\ Android \\ Xamarin.Android.Common.After.targets中定义的Import
元素。 Note this will likely disable support for adding C++ project references to Xamarin Android projects. 请注意,这可能会禁用对Xamarin Android项目添加C ++项目引用的支持。 Once you do one of those, your Xamarin Android project should build and run. 一旦你做了其中一个,你的Xamarin Android项目就应该构建并运行。
Long Version 长版
First, note the error in the VS output window: 首先,请注意VS输出窗口中的错误:
C:\\Program Files (x86)\\MSBuild\\Xamarin\\Android\\Xamarin.Android.Common\\ImportAfter\\Microsoft.Cpp.Android.targets(54,9): error MSB4044: The "MergeApkRecipelists" task was not given a value for the required parameter "RecipeFiles".
The Microsoft.Cpp.Android.targets file mentioned in the error looks to be all about supporting project references to C++ projects. 错误中提到的Microsoft.Cpp.Android.targets文件看起来就是支持对C ++项目的项目引用。 In it, the element for the MergeApkRecipelists
task looks like so: 在其中, MergeApkRecipelists
任务的元素如下所示:
<!-- language: lang-xml -->
<MergeApkRecipelists RecipeFiles="@(_NativeAndroidRecipeFiles)">
...
</MergeApkRecipelists>
The NativeAndroidRecipeFiles
variable doesn't seem to be defined in the .targets files, so presumably it's being initialized by the build process. NativeAndroidRecipeFiles
变量似乎没有在.targets文件中定义,因此可能是由构建过程初始化。 But since the .targets file seems to be aimed at supporting C++ project refs, I tried adding an Android C++ shared library project to my solution: 但由于.targets文件似乎旨在支持C ++项目引用,我尝试在我的解决方案中添加一个Android C ++共享库项目:
Then I referenced the C++ project from my Xamarin Android project, and voila! 然后我从我的Xamarin Android项目中引用了C ++项目,瞧! Building and running afterwards was successful. 之后的建立和运行是成功的。
But since it's pretty onerous to have to bring in a dummy lib, I also tracked down where Xamarin's Microsoft.Cpp.Android.targets file gets pulled in. This happens in the C:\\Program Files (x86)\\MSBuild\\Xamarin\\Android\\Xamarin.Android.Common.After.targets file, which has one Import
element: 但是由于必须引入一个虚拟库是非常繁重的,我还追踪了Xamarin的Microsoft.Cpp.Android.targets文件被拉入的位置。这发生在C:\\ Program Files(x86)\\ MSBuild \\ Xamarin \\ Android \\ Xamarin.Android.Common.After.targets文件,它有一个Import
元素:
<!-- language: lang-xml -->
<Import Project="$(MSBuildThisFileDirectory)\Xamarin.Android.Common\ImportAfter\*"
Condition="Exists('$(MSBuildThisFileDirectory)\Xamarin.Android.Common\ImportAfter')"/>
That brings in everything under %PROGRAMFILES(x86)\\MSBuild\\Xamarin\\Android\\Xamarin.Android.Common\\ImportAfter. 这带来了%PROGRAMFILES(x86)\\ MSBuild \\ Xamarin \\ Android \\ Xamarin.Android.Common \\ ImportAfter下的所有内容。 Since the only item in that directory is the .targets file we want to exclude, this can be commented out without affecting anything else. 由于该目录中唯一的项目是我们要排除的.targets文件,因此可以在不影响其他任何内容的情况下对其进行注释。 But note that, since this .targets file appears to be part of support for referencing C++ projects from Xamarin Android projects, commenting this out presumably means that will no longer work properly. 但请注意 ,由于此.targets文件似乎是支持从Xamarin Android项目引用C ++项目的一部分,因此对此进行评论可能意味着将无法正常工作。
With that Import
statement commented out, the Xamarin Android project should build and run without any C++ references. 随着Import
语句的注释,Xamarin Android项目应该在没有任何C ++引用的情况下构建和运行。
Just add the following condition on line 54 of the targets file at C:\\Program Files (x86)\\MSBuild\\Xamarin\\Android\\Xamarin.Android.Common\\ImportAfter\\Microsoft.Cpp.Android.targets: 只需在目标文件的第54行添加以下条件:C:\\ Program Files(x86)\\ MSBuild \\ Xamarin \\ Android \\ Xamarin.Android.Common \\ ImportAfter \\ Microsoft.Cpp.A ndroid.targets:
<MergeApkRecipelists RecipeFiles="@(_NativeAndroidRecipeFiles)" Condition="'@(_NativeAndroidRecipeFiles)' != ''">
Note: this permanent fix will ship soon in the alpha channel. 注意:此永久修复程序很快将在Alpha通道中发布。
从http://developer.xamarin.com/releases/vs/xamarin.vs_3/xamarin.vs_3.9/更新Xamarin我做到了,它的工作原理。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.