Yesterday I've downloaded the new version of Xamarin.Android which was 4.6.2. When I tried to build my project which correctly worked in previous versions (<4.6) now I get the following error:
(sorry it's in Russian)
Ошибка 1 непредвиденная ошибка при выполнении задачи "LinkAssemblies".
System.ArgumentOutOfRangeException: Заданный аргумент находится вне диапазона допустимых значений.
в Mono.Collections.Generic.Collection`1.get_Item(Int32 index)
в Mono.Cecil.Mdb.MdbReader.ReadLocalVariables(MethodEntry entry, MethodBody body, Scope[] scopes)
в Mono.Cecil.Mdb.MdbReader.Read(MethodBody body, InstructionMapper mapper)
в Mono.Cecil.Cil.CodeReader.ReadMethodBody()
в Mono.Cecil.Cil.CodeReader.ReadMethodBody(MethodDefinition method)
в Mono.Cecil.MethodDefinition.<get_Body>b__2(MethodDefinition method, MetadataReader reader)
в Mono.Cecil.ModuleDefinition.Read[TItem,TRet](TItem item, Func`3 read)
в Mono.Cecil.MethodDefinition.get_Body()
в Mono.Linker.Steps.MarkStep.ProcessMethod(MethodDefinition method)
в Mono.Linker.Steps.MarkStep.ProcessQueue()
в Mono.Linker.Steps.MarkStep.Process()
в Mono.Linker.Steps.MarkStep.Process(LinkContext context)
в Mono.Linker.Pipeline.Process(LinkContext context)
в MonoDroid.Tuner.Linker.Process(LinkerOptions options, LinkContext& context)
в Xamarin.Android.Tasks.LinkAssemblies.Execute()
в Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
в Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__20.MoveNext() AndroidApplication7
Text in russian means:
Error 1 Unexpected error while trying to execute task "LinkAssemblies".
System.ArgumentOutOfRangeException: Provided argument is out off range
I've spent a lot of time trying to understand this bug and found that the bug appears when (both):
- using Android.Support.V4 lib
- building with linking mode set to Full
So, I think this is the Linker bug connected with the Support Library. No matter what class or namespace of Android.Support.V4 is used the bug appears instantly.
Trying to make things clear I've made a sample project with one FragmentActivity and one DialogFragment nothing else. And I've reproduced this issue on it!
I want to know is there whether the temporary or instant solution to this breaking issue? This is very important, cause this freezes our development process. Yes, I know that this issue was posted to bug-tacker https://bugzilla.xamarin.com/show_bug.cgi?id=7946
Here is how I made my Sample Project.
- Pressed "New project" in Visual Studio 2012 and selected "Android Application"
- Changed "Minimum Android to target" to 1.6
- Set "Configuration properties" "Linking" to "Sdk and User Assemblies"
- Added reference to Android.Mono.Support.V4
- Added\Changed two source files
Activity1:
public class Activity1 : FragmentActivity
{
int count = 1;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
// Get our button from the layout resource,
// and attach an event to it
Button button = FindViewById<Button>(Resource.Id.MyButton);
button.Click += delegate { button.Text = string.Format("{0} clicks!", count++);
DialogFragment messageFragment = MyDialogFragment.GetInstance();
messageFragment.Show(SupportFragmentManager, "MessageDialog");
};
}
}
MyDialogFragment:
public class MyDialogFragment : DialogFragment
{
public override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
}
public static MyDialogFragment GetInstance()
{
return new MyDialogFragment();
}
public override Dialog OnCreateDialog(Bundle savedInstanceState)
{
var builder = new AlertDialog.Builder(Activity);
builder.SetMessage("Message");
builder.SetPositiveButton("Ok", (sender, args) => { });
return builder.Create();
}
}
I think anyone can reproduce it. If not please comment on what you've done.