I'm getting an Android linker error I can't figure out. Any hints that would help with a workaround would be welcome, including more info about what Xamarin does behind the scenes, as it's sort of a black box.
Build actions and results
If I do a clean followed by an "Archive For Publishing", then I get the "LinkAssemblies task failed unexpectedly" error with details as follows:
Error MSB4018: The "LinkAssemblies" task failed unexpectedly.
System.ArgumentException: An item with the same key has already been added.
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
2.Insert(TKey key, TValue value, Boolean add) at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable1 source, Func
2 keySelector, Func2 elementSelector, IEqualityComparer`1 comparer)
at MonoDroid.Tuner.MarkJavaObjects.GetTypesInModule(ModuleDefinition module)
at MonoDroid.Tuner.MarkJavaObjects.FindType(TypeDefinition type, String fullname)
at MonoDroid.Tuner.MarkJavaObjects.GetHelperType(TypeDefinition type, String suffix)
at MonoDroid.Tuner.MarkJavaObjects.PreserveAdapter(TypeDefinition type)
Inside my Android app's csproj file I have the following:
<Target Name="Obfuscate" AfterTargets="_CopyIntermediateAssemblies" Condition="'$(Configuration)' == 'Release'"> <Exec Command="RunAndroidObfuscate.bat" WorkingDirectory="." /> </Target>
My batch file replaces the main app DLL with an obfuscated version in the following folder. It is set up to only modify that single DLL:
The obfuscation is running without errors and successfully replaces the DLL.