在调试模式下使用多dex的Xamarin Android存在问题

9

我创建了一个Xamarin Forms应用程序。我在Android上使用multidex(许多库)。 我使用multidex.keep文件并选择MultiDexMainDexList选项。现在部署正常运作。但是在调试模式下我遇到了异常:

 System.ArgumentException: The offset and length have exceeded the bounds of the array or the counter value exceeds the number of elements from the pointer to the end of the original collection.
 в System.Buffer.BlockCopy(Array src, Int32 srcOffset, Array dst, Int32 dstOffset, Int32 count)
 в Mono.Cecil.Metadata.GuidHeap.Read(UInt32 index)
 в Mono.Cecil.MetadataReader.InitializeCustomDebugInformations()
 в Mono.Cecil.MetadataReader.GetCustomDebugInformation(ICustomDebugInformationProvider provider)
в Mono.Cecil.Cil.PortablePdbReader.Read(MethodDefinition method)
в Mono.Cecil.Cil.CodeReader.ReadMethodBody()
в Mono.Cecil.Cil.CodeReader.ReadMethodBody(MethodDefinition method)
в Mono.Cecil.MethodDefinition.<>c.<get_Body>b__41_0(MethodDefinition method, MetadataReader reader)
в Mono.Cecil.ModuleDefinition.Read[TItem,TRet](TRet& variable, TItem item, Func`3 read)
в Mono.Cecil.MethodDefinition.get_Body()
 Mono.Cecil.MethodDefinition.get_DebugInformation()
в Mono.Debugging.Soft.SoftDebuggerSession.LoadPdbType(TypeDefinition type, Dictionary`2 fileToSourceFileInfos)
в Mono.Debugging.Soft.SoftDebuggerSession.LoadPdbFile(String assemblyFileName, String pdbFileName)
в Mono.Debugging.Soft.SoftDebuggerSession.LoadDebugFile(String assemblyFileName, String debugFileName, Func`3 loadDebugFile)
в Mono.Debugging.Soft.SoftDebuggerSession.CheckBetterMatch(TypeMirror type, String file, Int32 line, Int32 column, Location found)
в Mono.Debugging.Soft.SoftDebuggerSession.FindLocationByMethod(MethodMirror method, String file, Int32 line, Int32 column, Boolean& insideTypeRange)
в Mono.Debugging.Soft.SoftDebuggerSession.FindLocationByType(TypeMirror type, String file, Int32 line, Int32 column, Boolean& genericMethod, Boolean& insideTypeRange)
в Mono.Debugging.Soft.SoftDebuggerSession.ResolveBreakpoints(TypeMirror type)
в Mono.Debugging.Soft.SoftDebuggerSession.HandleTypeLoadEvents(TypeLoadEvent[] events)
в Mono.Debugging.Soft.SoftDebuggerSession.HandleEventSet(EventSet es)
в Mono.Debugging.Soft.SoftDebuggerSession.EventHandler()

我使用dex2jar和Java Decompiler进行分析(参考这篇文章)。但现在我不知道该寻找什么问题。

有任何想法吗?


所以这是在“Debug”配置中发生的。上面的异常看起来更像是连接到软调试器的问题。由于上面的跟踪中没有任何Multidex任务的痕迹,我不确定它是否与Multidex有关,直到我们有一个最小的重现。你能在你的帖子中添加一个吗? - Jon Douglas
嗨,Jon。我的调试器现在正常工作了!这是我的项目出了问题。我在我的项目中使用的是XF 2.3.4.247。我安装了XF 2.3.5.239(预发布版),然后将其删除并安装了稳定版本2.3.4.247。之后调试就可以工作了。 谢谢你的博客 - 这是非常有用的信息。我正在期待你关于Xamarin Android的书籍。 - FetFrumos
1个回答

0

我解决了这个问题。

以下是我的用户案例详细描述:

  1. 我使用了PCL库。
  2. 我需要将Azure Mobile Client更新到4.0版本。这个版本不支持PCL,只支持.NET Standard 1.4。
  3. 但是我有一个使用Xamarin Forms的Windows Phone项目。WP不支持.NET Standard 1.4。
  4. 我在我的解决方案中添加了一个新的库(.NET Standard 1.4)。我从我的PCL中添加了文件链接到这个库中。
  5. 然后出现了这个错误。起初它是一个浮动错误 - 但后来变成了永久性错误。
  6. 我花了两个完整的工作日寻找这个错误的原因。我找到了应用程序崩溃的地方。
  7. 我从我的库(.Net Standard)中删除了相关文件,然后重新添加。现在调试可以正常工作。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接