在xamarin studio中尝试构建我的android项目时,我经常遇到如下错误:

C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2,2):
Error: Exception while loading assemblies: System.IO.FileNotFoundException:
Could not load assembly 'Mono.Android.Support.v4, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065'.
Perhaps it doesn't exist in the Mono for Android profile?
File name: 'Mono.Android.Support.v4.dll'
   at Xamarin.Android.Tuner.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters)
   at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(ICollection`1 assemblies, AssemblyDefinition assembly, Boolean topLevel)
   at Xamarin.Android.Tasks.ResolveAssemblies.Execute() (Akva20150407)

-
C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2,2):
Error: Exception while loading assemblies: System.IO.FileNotFoundException:
Could not load assembly 'Xamarin.Android.Support.v4, Version=1.0.0.0, Culture=neutral, PublicKeyToken='.
Perhaps it doesn't exist in the Mono for Android profile?
File name: 'Xamarin.Android.Support.v4.dll'
   at Xamarin.Android.Tuner.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters)
   at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(ICollection`1 assemblies, AssemblyDefinition assembly, Boolean topLevel)
   at Xamarin.Android.Tasks.ResolveAssemblies.Execute() (Akva20150407)

-
C:\progge\Apper\Akva20150407\Akva20150407\Act_MainGUI.cs(29,29):
Error CS0433: The type 'Android.Support.V4.App.FragmentActivity' exists in both
'c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v5.0\Mono.Android.Support.v4.dll' and
'c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v5.0\Xamarin.Android.Support.v4.dll'
(CS0433) (Akva20150407)

我必须将xamarin.android.support.v4添加到monoandroid文件夹,否则它会抱怨找不到它。
我必须将mono.android.support.v4添加到monoandroid文件夹,否则它会抱怨找不到它。
如果我同时添加这两个,它将抱怨在两个包中都可以找到fragmentactivity。
这些包是通过nuget安装的。
看起来很自相矛盾…我到底该怎么做才能让这工作??

最佳答案

升级您的Xamarin Studio
这个错误是在Xamarin Studio:5.7.0.436中修复的。
查看错误报告:https://bugzilla.xamarin.com/show_bug.cgi?id=24276

10-07 19:49
查看更多