question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Xamarin.Android linking fails with TargetFramework 7.0

See original GitHub issue

As some people have mentioned in #439, the linking of Xamarin.Android fails with the following error message when using the hosted agent:

2016-12-04T16:39:27.4138913Z "C:\a\1\s\Droid\TestApp.Droid.csproj" (Clean;clean;PackageForAndroid target) (1) ->
2016-12-04T16:39:27.4138913Z (_LinkAssembliesShrink target) -> 
2016-12-04T16:39:27.4148783Z   C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1616,5): error MSB4018: The "LinkAssemblies" task failed unexpectedly. [C:\a\1\s\Droid\TestApp.Droid.csproj]
2016-12-04T16:39:27.4158787Z C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1616,5): error MSB4018: Xamarin.Android.XamarinAndroidException: error XA2006: Reference to metadata item 'System.IO.MonoIOError' (defined in 'System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e') from 'System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' could not be resolved. ---> Mono.Cecil.ResolutionException: Failed to resolve System.IO.MonoIOError [C:\a\1\s\Droid\TestApp.Droid.csproj]
2016-12-04T16:39:27.4158787Z C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1616,5): error MSB4018:    at Mono.Linker.Steps.MarkStep.MarkType(TypeReference reference) [C:\a\1\s\Droid\TestApp.Droid.csproj]
2016-12-04T16:39:27.4158787Z C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1616,5): error MSB4018:    at MonoDroid.Tuner.MonoDroidMarkStep.MarkType(TypeReference reference) [C:\a\1\s\Droid\TestApp.Droid.csproj]
2016-12-04T16:39:27.4158787Z C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1616,5): error MSB4018:    at Mono.Linker.Steps.MarkStep.MarkMethodBody(MethodBody body) [C:\a\1\s\Droid\TestApp.Droid.csproj]
2016-12-04T16:39:27.4158787Z C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1616,5): error MSB4018:    at Mono.Linker.Steps.MarkStep.ProcessMethod(MethodDefinition method) [C:\a\1\s\Droid\TestApp.Droid.csproj]
2016-12-04T16:39:27.4158787Z C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1616,5): error MSB4018:    at Mono.Linker.Steps.MarkStep.ProcessQueue() [C:\a\1\s\Droid\TestApp.Droid.csproj]
2016-12-04T16:39:27.4158787Z C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1616,5): error MSB4018:    at Mono.Linker.Steps.MarkStep.Process() [C:\a\1\s\Droid\TestApp.Droid.csproj]
2016-12-04T16:39:27.4168781Z C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1616,5): error MSB4018:    at Mono.Linker.Pipeline.Process(LinkContext context) [C:\a\1\s\Droid\TestApp.Droid.csproj]
2016-12-04T16:39:27.4168781Z C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1616,5): error MSB4018:    at MonoDroid.Tuner.Linker.Process(LinkerOptions options, LinkContext& context) [C:\a\1\s\Droid\TestApp.Droid.csproj]
2016-12-04T16:39:27.4228774Z C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1616,5): error MSB4018:    at Xamarin.Android.Tasks.LinkAssemblies.Execute() [C:\a\1\s\Droid\TestApp.Droid.csproj]
2016-12-04T16:39:27.4228774Z C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1616,5): error MSB4018:    --- End of inner exception stack trace --- [C:\a\1\s\Droid\TestApp.Droid.csproj]
2016-12-04T16:39:27.4228774Z C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1616,5): error MSB4018:    at Xamarin.Android.Diagnostic.Error(Int32 code, Exception innerException, String message, Object[] args) [C:\a\1\s\Droid\TestApp.Droid.csproj]
2016-12-04T16:39:27.4228774Z C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1616,5): error MSB4018:    at Xamarin.Android.Tasks.LinkAssemblies.Execute() [C:\a\1\s\Droid\TestApp.Droid.csproj]
2016-12-04T16:39:27.4228774Z C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1616,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [C:\a\1\s\Droid\TestApp.Droid.csproj]
2016-12-04T16:39:27.4228774Z C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1616,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() [C:\a\1\s\Droid\TestApp.Droid.csproj]

I set the linker behaviour to SdkOnly. If I disable linking completely the build succeeds but obviously the APK file gets much bigger.

I’ve currently set the target framework to use the latest installed platform, which causes it to use v7.0. This can I also confirm by the logs. As you can see in #439, it’s working for @InquisitorJax and @msimecek if they switch the target framework to version v6.0. I also tried setting the TargetFrameworkVersion to v6.0 and can confirm that it works correctly.

I created a test repo for you to test and confirm the issue. It has a master branch that has it’s TargetFrameworkVersion set to v7.0 and another branch named AndroidM that has it’s TargetFrameworkVersion set to v6.0

https://github.com/fela98/android-n-vsts-test

Here the settings of the Xamarin.Android build task that I use: screen shot 2016-12-04 at 15 37 25

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
jeronecommented, Jan 12, 2017

The Linker error you are seeing is due the hosted build VMs not having Xamarin.Android 7.0 support though the Android SDK 24 is installed. We will be updating them early next year after the holidays.

Hi @madhurig, is there any more detailed ETA when the Android SDK version will be updated?

0reactions
madhurigcommented, Jan 13, 2017

@jerone : Thanks for confirming.

Read more comments on GitHub >

github_iconTop Results From Across the Web

XF 2.5 build failed targeting Xamarin.Android 7.0 or 6.0 #2016
I want to create an app using XF 2.5 with Xamarin.Android 7.0, but it says build failed with the following error:.
Read more >
How do I resolve a Target Framework Error for Xamarin.Android
Turns out that even after changing the target framework in the properties of my Android project it was not reflecting in the .csproj...
Read more >
Error while deploying on device in Xamarin.Android after ...
Try the follows: 1.What's the version of the nuget package? Update Xamarin.Android.Support.v7.AppCompat package and Xamarin.Forms to the lastest ...
Read more >
Error when updating target framework to Android 10.0 (Q)
The message is : "Severity Code Description Project File Line Suppression State Error Can not resolve reference: `Xamarin. Android.
Read more >
xamarin forms target framework error - Visual Studio Feedback
Hi! We have identified the issue. To avoid that warning you need to install API Level 24 (via Android Studio) and make your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found