Reputation: 691
I am working on Xamarin.Forms project for my company and we plan to release our app on IOS and Android (Using Visual Studio Community Edition on Macbook pro). So far everything seemed to be OK. And then suddenly I cannot build debug or release on Android project. I am getting this error:
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(2,2): Error: Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'Xamarin.Android.Support.Compat, Version=1.0.0.0, Culture=neutral, PublicKeyToken='. Perhaps it doesn't exist in the Mono for Android profile?
File name: 'Xamarin.Android.Support.Compat.dll'
at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference reference, Mono.Cecil.ReaderParameters parameters) [0x00099] in /Users/builder/data/lanes/5147/c2a33d8e/source/xamarin-android/external/Java.Interop/src/Java.Interop.Tools.Cecil/Java.Interop.Tools.Cecil/DirectoryAssemblyResolver.cs:220
at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference reference) [0x00000] in /Users/builder/data/lanes/5147/c2a33d8e/source/xamarin-android/external/Java.Interop/src/Java.Interop.Tools.Cecil/Java.Interop.Tools.Cecil/DirectoryAssemblyResolver.cs:170
at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences (Java.Interop.Tools.Cecil.DirectoryAssemblyResolver resolver, System.Collections.Generic.ICollection`1[T] assemblies, Mono.Cecil.AssemblyDefinition assembly, System.Boolean topLevel) [0x0015c] in <593a6fd557984367bb21e275d0fa0659>:0
at Xamarin.Android.Tasks.ResolveAssemblies.Execute (Java.Interop.Tools.Cecil.DirectoryAssemblyResolver resolver) [0x0019c] in <593a6fd557984367bb21e275d0fa0659>:0
I am pretty sure I haven't changed any source files, it was building up until now.. The only App Compat I use is "Xamarin.Android.Support.v7.Compat".
The things I tried:
You are trying to install this package into a project that targets 'MonoAndroid,Version=v6.0', but the package does not contain any assembly references or content files that are compatible with that framework.
I am using Xamarin.Forms 2.4.0.38779. I tried removing all packages and updating for the newest Forms - still got same error.
This is packages.config for Droid project:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="modernhttpclient" version="2.4.2"
targetFramework="monoandroid60" />
<package id="Plugin.PushNotification" version="1.1.2"
targetFramework="monoandroid60" />
<package id="Rg.Plugins.Popup" version="1.0.4"
targetFramework="monoandroid60" />
<package id="Xam.Plugin.DeviceInfo" version="3.0.2"
targetFramework="monoandroid60" />
<package id="Xam.Plugins.Settings" version="3.1.1"
targetFramework="monoandroid60" />
<package id="Xamarin.Android.Support.Animated.Vector.Drawable"
version="23.3.0" targetFramework="monoandroid60" />
<package id="Xamarin.Android.Support.Design" version="23.3.0"
targetFramework="monoandroid60" />
<package id="Xamarin.Android.Support.v4" version="23.3.0"
targetFramework="monoandroid60" />
<package id="Xamarin.Android.Support.v7.AppCompat" version="23.3.0"
targetFramework="monoandroid60" />
<package id="Xamarin.Android.Support.v7.CardView" version="23.3.0"
targetFramework="monoandroid60" />
<package id="Xamarin.Android.Support.v7.MediaRouter" version="23.3.0"
targetFramework="monoandroid60" />
<package id="Xamarin.Android.Support.v7.RecyclerView" version="23.3.0"
targetFramework="monoandroid60" />
<package id="Xamarin.Android.Support.Vector.Drawable"
version="23.3.0"
targetFramework="monoandroid60" />
<package id="Xamarin.Forms" version="2.4.0.38779"
targetFramework="monoandroid60" />
</packages>
I will provide any logs, if needed.
Upvotes: 4
Views: 2756
Reputation: 881
Try these steps (it worked for me):
Get-ChildItem 'bin','obj','.vs','*.user' -Recurse | ForEach-Object { Remove-Item $_.FullName -Force -Recurse }
to delete all bin, obj and other cache filesdotnet clean
to prepare solutiondotnet restore
to restore all packagesdotnet build
to build the solutionUpvotes: 0
Reputation: 1000
I have been working on Xamarin projects on my Macbook Pro for the better part of this year to know these type of issues.
This would usually happen if you copy a Xamarin project running on OSX to Windows or visa versa.
The solution is always the same. List down all the used packages in your project. Do a whole removal of the packages and reinstall them again cleanly with their specified version numbers.
Upvotes: 0
Reputation: 691
So after enabling detailed build output I found the issue!
Xamarin is really bad with it's error description, and by investigating into Build Log I found out that this missing dll was required by Plugin.PushNotification NuGet package I use for both iOS and Android. After removing all references to this package from Android project, it started building again!
Upvotes: 3