1

这是我尝试在发布模式下运行时遇到的异常:

4>  C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1124,3): error MSB4018: The "BuildApk" task failed unexpectedly. 
4>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1124,3): error MSB4018: System.ArgumentException: An item with the same key has already been added. 
4>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1124,3): error MSB4018:    at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) 
4>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1124,3): error MSB4018:    at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add) 
4>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1124,3): error MSB4018:    at Ionic.Zip.ZipFile._InternalAddEntry(ZipEntry ze) 
4>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1124,3): error MSB4018:    at Ionic.Zip.ZipFile.AddFile(String fileName, String directoryPathInArchive) 
4>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1124,3): error MSB4018:    at Xamarin.Android.Tasks.BuildApk.AddAssemblies(ZipFile apk) 
4>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1124,3): error MSB4018:    at Xamarin.Android.Tasks.BuildApk.Execute() 
4>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1124,3): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
4>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1124,3): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__20.MoveNext() 

任何人有任何建议我该如何解决这个问题?

4

2 回答 2

1

我通过清洁项目解决了这个问题。右键单击项目名称 -> 清理。

于 2014-04-25T08:41:13.660 回答
0

发生这种情况是因为它试图将两个具有相同名称的文件添加到存档中。检查项目文件的 XML 是否有重复项。顺便说一句,您的项目很可能实际上在资源管理器中显示了两次文件,并且您已将其视为异常或错误而将其驳回,因此这可能暗示了哪个文件是问题所在。

于 2013-06-18T12:16:15.137 回答