I have just updated a large Xamarin project from MVVMCross version 3.5 to 4.0. I have fixed all namespace issues and bugs, but I am stuck with this bug:
The "LinkAssemblies" task failed unexpectedly.
Xamarin.Android.XamarinAndroidException: error XA2006: Reference to metadata item
'System.Boolean Android.OS.BaseBundle::GetBoolean(System.String,System.Boolean)'
(defined in 'MvvmCross.Droid.FullFragging, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=null') from 'MvvmCross.Droid.FullFragging, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=null' could not be resolved. --->
Mono.Cecil.ResolutionException:
Failed to resolve System.Boolean Android.OS.BaseBundle::
GetBoolean(System.String,System.Boolean)
I have added MvvmCross.Droid.FullFragging.* to linkerConfig.xml, but to no avail.
I experienced the same issue. The MvvmCross dlls are build to version v6.0 for android. I noticed the following output tab (My logging is set to verbose).
warning XA0105: The $(TargetFrameworkVersion) for MvvmCross.Binding.Droid.dll (v6.0) is greater than the $(TargetFrameworkVersion) for your project (v5.0).
When I changed the projects to Android 6.0 I still received the linker error. When I opened the project file in a text editor I noticed that was defined twice. Once in the global property group set to 6.0 and once in the Debug property group set to 5.0. I removed the following line from the Debug property group and the issue went away.
<TargetFrameworkVersion>v5.0</TargetFrameworkVersion>
What you need to do is to switch on verbose logging in your build. For iOS specify verbose logging by adding:
-v -v -v -v
To the extra build parameters textbox. Then run the build again.
For Android you can do this in the Visual Studio Tools -> Settings -> Xamarin -> Android settings -> Xamarin Diagnostics.
You will probably identify that some packages are of different versions and will cause this linking issue.
You will find some clues to the issue using verbose logging. I have only mentioned the verbose logging for this platform as its the platform I have most experience with at the moment.
This is the best answer I can offer as this issue can be caused by a truly massive number of issues and will be individual to each solution.
Related
I have tried creating Android projects and cross platform projects that utilize Xamarin in Visual studio. When I build, even an empty project, it fails instantly without seeming to perform any work.
There are no errors or warnings listed.
The output window has the project name and:
Build: 0 succeeded, 2 failed, 0 up-to-date, 0 skipped
When I start the project I get message boxes warning me about unexpected logger failures and sometimes the dialogs reference the MuxLogger. This is inconsistent, the messages vary slightly and sometimes don't appear at all. Here is an example:
Incidentally I tried manually building to get more output and I get this:
Unhandled Exception: System.TypeLoadException: Could not load type 'Microsoft.Build.Logging.ProfilerLogger' from assembly 'Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
at System.Signature.GetSignature(Void* pCorSig, Int32 cCorSig, RuntimeFieldHandleInternal fieldHandle, IRuntimeMethodInfo methodHandle, RuntimeType declaringType)
at System.Reflection.RuntimeMethodInfo.FetchNonReturnParameters()
at System.Reflection.RuntimeMethodInfo.GetParameters()
at System.Diagnostics.StackTrace.ToString(TraceFormat traceFormat)
at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)
at System.Exception.GetStackTrace(Boolean needFileInfo)
at System.Exception.ToString(Boolean needFileLineInfo, Boolean needMessage)
at System.Exception.ToString()
at Microsoft.Build.CommandLine.MSBuildApp.Execute(String commandLine)
at Microsoft.Build.CommandLine.MSBuildApp.Main()
Note that I can build many other project types such as web projects and MonoGame projects just fine.
Ultimately this turned out to be a problem with an old version of MSBuild installed in the Global Assembly Cache (GAC). To check for this, first open an instance of Developer Command Prompt for VS2017. Then output the assemblies in your GAC to a file for easy review:
gacutil -l >> someFile.txt
Look for anything that starts with Microsoft.Build, specifically lines that include Version=15.X (hint, these don't output in order so sort the lines alphabetically).
Uninstall all things that start with Microsoft.Build which may include Microsoft.Build.Framework, Microsoft.Build and more. This should not install versions of Microsoft.Build with a version < 15. Command:
gacutil -u Microsoft.Build
and
gacutil -u Microsoft.Build.Framework
This should allow your project to utilize the correct version of MSBuild and compile successfully.
I have a Xamarin iOS project where I have just added SQLCipher to my packages. I now get a build error saying:
iOS/MTOUCH: Error MT0034: Cannot reference 'monotouch.dll' in a
Xamarin.iOS project - it is implicitly referenced by
'SQLite.Net.Platform.SQLCipher.XamarinIOS, Version=4.1.1.0,
Culture=neutral, PublicKeyToken=null'. (MT0034) (myProject.iOS)
I'm not sure how to fix this, I have tried deleting the sqlcipher package and adding again, rebuilding, and restarting Xamarin but no luck. Thanks for any help
When I try to build the application I get an exception the following exception :
C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(681,3): error : Failed to resolve assembly: 'Java.Interop, Version=0.1.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065'
I tried cleaning the project and building it again, also updated the Xamarin.Forms packages but still with no luck.
A little overview on the stack trace :
2>C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(681,3): error : Failed to resolve assembly: 'Java.Interop, Version=0.1.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065'
2> Tool /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/bin/mtouch execution finished. (TaskId:153)
2> MTouch: 2016-07-05T14:27:15.8191415+05:30 - Finished (TaskId:153)
2> Output Item(s): _NativeLibrary= (TaskId:153)
2>Done executing task "MTouch" -- FAILED. (TaskId:153)
Has anyone received this error? I am running the latest Xamarin for Visual Studio.
As mentioned in the comments above by #SushiHangover Java.Interop.dll is from Xamarin.Android and I was getting an error in Xamarin.IOS.
I had a reference of Mono.Android in PCL which is always referenced in Xamarin.IOS so indirectly I was referencing dll of Xamarin.Android to Xamarin.IOS. Removing the reference from PCL solved my problem.
Step-by-step instructions on how to fish this one out, as it took me some time to find where the 'Android polluted' peace of code was.
Unload your Common code project
Open .csproj look for something like this
<ItemGroup>
<Reference Include="Mono.Android">
<HintPath>..\..\..\..\..\..\..\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v11.0\Mono.Android.dll</HintPath>
</Reference>
Delete this segment from csproj.
Load the project
Clean and rebuild the solution having iOS as startup Project, at this point, you will get a build error that will show which .cs file fails to build due to missing reference.
Go there and move the mechanism to an Android specific project.
As mentioned by #AkashAmin 'Mono.Android' referenced should not be there in PCL project.
But with this, also make sure that you have not added any 'Android' specific code in PCL project by adding 'using Android', if this was done then you need to remove this code by using 'Dependency Services', Click here
I had the same problem and when I removed the android.mono reference from pcl project it worked fine.
I think it happens because we are building project in ios and it doesn't have any android libraries
Platform specific code within the Shared Project will cause iOS compiler to attempt to use the platform specific assemblies when compiling.
In my case, I had a reference within my Shared Project's code, within the "using" statements, which was causing iOS to attempt to link to Android specific assemblies.
Removing the code from the Shared Project allowed for successful compiling of the project.
Just in case, I got this error from working with ReSharper on VS2013 (https://bugzilla.xamarin.com/show_bug.cgi?id=41627).
What I did was use the Workaround to explicitly add java.interop.dll assembly to my project. This problem doesn't affect Build so you can deploy first and VS will download java.interop to your app's obj\Debug\linksrc folder, which you can reference...
You need to check your PLC project on Android link. In PLC project ctrl+f and lets go find "Android" and delete it.
My team recently tried to upgrade our WorkerRoles project to use Azure 2.5. But I've spent days on it and have had no joy resolving some weird worker role recycling issues and due to time pressure we're rolling back to Azure 2.3.
However, after changing all the references and the app.config file, when I try to run I get the following exception:
System.IO.FileLoadException was unhandled
Message: An unhandled exception of type 'System.IO.FileLoadException' occurred in WaWorkerHost.exe
Additional information: Could not load file or assembly 'Microsoft.WindowsAzure.Diagnostics, Version=2.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
I tried changing my app.config bindings, etc. And it seems fine to me. Then I noticed a warning in the error console:
Found conflicts between different versions of the same dependent assembly that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed.
So I ran my build again with the "give me lots of info" setting and I think I've found the issue:
2> Unified Dependency "Microsoft.WindowsAzure.ServiceRuntime, Version=2.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35".
2> Using this version instead of original version "2.3.0.0" in "C:\Users\craig.brett\repos\Admin\WorkersPlus\bin\Craig\WorkersPlus.dll" because AutoUnify is 'true'.
2> Resolved file path is "C:\Program Files\Microsoft SDKs\Azure\.NET SDK\v2.5\ref\Microsoft.WindowsAzure.ServiceRuntime.dll".
...
2> Unified Dependency "Microsoft.WindowsAzure.Diagnostics, Version=2.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35".
2> Using this version instead of original version "2.3.0.0" in "C:\Users\craig.brett\repos\Admin\WorkersPlus\bin\Craig\WorkersPlus.dll" because AutoUnify is 'true'.
2> Resolved file path is "C:\Program Files\Microsoft SDKs\Azure\.NET SDK\v2.5\bin\plugins\Diagnostics\Microsoft.WindowsAzure.Diagnostics.dll".
This all looks very suspect to me, when I'm trying to get it to use 2.3. Is there something I need to do to roll back to 2.3? Do I have to uninstall (or attempt to) the Azure 2.5 SDK entirely?
Thanks to Simon Opelt's comment, I went back and did a git diff against the version prior to the update focused on the effected projects.
They revealed that the Azure Caching NuGet package was still at version 2.5, as well as the several sub-libraries of it. There were also a few other Microsoft.* packages that had gone up a few versions. So I used code similar to the following to selectively go through and revert the changes:
git checkout -p <hash of commit prior to Azure upgrade> -- ProjectWorker\ProjectWorker.csproj
git checkout -p <hash of commit prior to Azure upgrade> -- ProjectWorker\packages.config
I took no chances and also rolled back the Azure ServiceBus package.
After this process, things ran fine again! Not quite as easy as it should have been, but at least we're working again and can upgrade at a later date.
I have issue when building an Mvvmcross 3.1.1 (nuget) application. I am getting this exception during second phase build (packaging the apk) on my solution
C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(970,5): error MSB4018: Xamarin.Android.XamarinAndroidException: error XA2006:
Reference to metadata item 'System.Void Android.Views.View::set_Activated(System.Boolean)' (defined in 'Cirrious.MvvmCross.Binding.Droid, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null') from 'Cirrious.MvvmCross.Binding.Droid, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' could not be resolved.\r
This seems similar to this issue #629. While my manifest is ok:
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="15" />
I am using latest nuget Mvvmcross 3.1.1.
Thanks
That's probably due to the Linker on your Android project. Is Linking set on "Sdk and User Assemblies"? If yes: You need to compile with a higher Sdk version due to this bug. I hope the link may help you in case you want to keep the linker like that.