Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

Question Android IL2CPP fails in 2021.2.0b15

Discussion in '2021.2 Beta' started by Wattosan, Oct 22, 2021.

  1. Wattosan

    Wattosan

    Joined:
    Mar 22, 2013
    Posts:
    460
    Hello,

    I am trying to make an Android IL2CPP Development build with ARM64 as the target architecture. The mono build works fine. Code stripping is not enabled and set to minimal.

    The error I am getting is the following:
    C:\Program Files\Unity\Hub\Editor\2021.2.0b15\Editor\Data\il2cpp\build\deploy\il2cpp.exe @Library\Bee\artifacts\rsp\11800186649846153120.rsp
    Error: IL2CPP error for method 'T& System.Span`1::get_Item(System.Int32)' in assembly 'C:\Projects\Unity\Futuclass\futuclass\Futuclass\Library\Bee\artifacts\Android\ManagedStripped\System.Memory.dll'
    System.InvalidOperationException: Sequence contains no matching element
    at System.Linq.ThrowHelper.ThrowNoMatchException()
    at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source, Func`2 predicate)
    at Unity.IL2CPP.IntrinsicRemap.SpanGetItemArguments(ReadOnlyContext context, MethodReference callingMethod, MethodReference methodToCall, IRuntimeMetadataAccess runtimeMetadata, IEnumerable`1 arguments)
    at Unity.IL2CPP.IntrinsicRemap.GetCustomArguments(ReadOnlyContext context, MethodReference methodToCall, MethodReference callingMethod, IRuntimeMetadataAccess runtimeMetadata, IEnumerable`1 arguments)
    at Unity.IL2CPP.MethodBodyWriter.TryWriteIntrinsicMethodCall(String returnVariable, IGeneratedMethodCodeWriter writer, MethodReference callingMethod, MethodReference unresolvedMethodToCall, MethodReference methodToCall, IRuntimeMetadataAccess runtimeMetadataAccess, IReadOnlyList`1 argumentArray, Boolean useArrayBoundsCheck)
    at Unity.IL2CPP.MethodWriter.<>c__DisplayClass7_0.<WriteAdjustorThunk>b__0(IGeneratedMethodCodeWriter bodyWriter, IRuntimeMetadataAccess metadataAccess)
    at Unity.IL2CPP.CodeWriters.CodeWriterExtensions.WriteMethodWithMetadataInitialization(IGeneratedMethodCodeWriter writer, String methodSignature, Action`2 writeMethodBody, String uniqueIdentifier, MethodReference methodRef, Boolean writingMethodBody)
    at Unity.IL2CPP.MethodWriter.WriteAdjustorThunk(MethodWriteContext context, IGeneratedMethodCodeWriter writer)
    at Unity.IL2CPP.SourceWriter.WriteType(SourceWritingContext context, IGeneratedMethodCodeWriter writer, TypeReference type, NPath filePath, Boolean writeMarshalingDefinitions)
    at Unity.IL2CPP.SourceWriters.SourceWriterBase`2.WriteItem(StreamWorkItemData`2 data)
    at Unity.IL2CPP.Contexts.Scheduling.Streams.FileLevelParallelStreamManager`3.WorkerWriteItemsToFile(WorkItemData`2 data)
    at Unity.IL2CPP.Contexts.Scheduling.PhaseWorkScheduler`1.WorkerLoop(Object data)
    Error: IL2CPP error for method 'T& System.Span`1::get_Item(System.Int32)' in assembly 'C:\Projects\Unity\Futuclass\futuclass\Futuclass\Library\Bee\artifacts\Android\ManagedStripped\System.Memory.dll'
    System.InvalidOperationException: Sequence contains no matching element
    at System.Linq.ThrowHelper.ThrowNoMatchException()
    at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source, Func`2 predicate)
    at Unity.IL2CPP.IntrinsicRemap.SpanGetItemArguments(ReadOnlyContext context, MethodReference callingMethod, MethodReference methodToCall, IRuntimeMetadataAccess runtimeMetadata, IEnumerable`1 arguments)
    at Unity.IL2CPP.IntrinsicRemap.GetCustomArguments(ReadOnlyContext context, MethodReference methodToCall, MethodReference callingMethod, IRuntimeMetadataAccess runtimeMetadata, IEnumerable`1 arguments)
    at Unity.IL2CPP.MethodBodyWriter.TryWriteIntrinsicMethodCall(String returnVariable, IGeneratedMethodCodeWriter writer, MethodReference callingMethod, MethodReference unresolvedMethodToCall, MethodReference methodToCall, IRuntimeMetadataAccess runtimeMetadataAccess, IReadOnlyList`1 argumentArray, Boolean useArrayBoundsCheck)
    at Unity.IL2CPP.MethodWriter.<>c__DisplayClass7_0.<WriteAdjustorThunk>b__0(IGeneratedMethodCodeWriter bodyWriter, IRuntimeMetadataAccess metadataAccess)
    at Unity.IL2CPP.CodeWriters.CodeWriterExtensions.WriteMethodWithMetadataInitialization(IGeneratedMethodCodeWriter writer, String methodSignature, Action`2 writeMethodBody, String uniqueIdentifier, MethodReference methodRef, Boolean writingMethodBody)
    at Unity.IL2CPP.MethodWriter.WriteAdjustorThunk(MethodWriteContext context, IGeneratedMethodCodeWriter writer)
    at Unity.IL2CPP.SourceWriter.WriteType(SourceWritingContext context, IGeneratedMethodCodeWriter writer, TypeReference type, NPath filePath, Boolean writeMarshalingDefinitions)
    at Unity.IL2CPP.SourceWriters.SourceWriterBase`2.WriteItem(StreamWorkItemData`2 data)
    at Unity.IL2CPP.Contexts.Scheduling.Streams.FileLevelParallelStreamManager`3.WorkerWriteItemsToFile(WorkItemData`2 data)
    at Unity.IL2CPP.Contexts.Scheduling.PhaseWorkScheduler`1.WorkerLoop(Object data)
    Error: IL2CPP error for method 'T& modreq(System.Runtime.InteropServices.InAttribute) System.ReadOnlySpan`1::get_Item(System.Int32)' in assembly 'C:\Projects\Unity\Futuclass\futuclass\Futuclass\Library\Bee\artifacts\Android\ManagedStripped\System.Memory.dll'
    System.InvalidOperationException: Sequence contains no matching element
    at System.Linq.ThrowHelper.ThrowNoMatchException()
    at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source, Func`2 predicate)
    at Unity.IL2CPP.IntrinsicRemap.SpanGetItemArguments(ReadOnlyContext context, MethodReference callingMethod, MethodReference methodToCall, IRuntimeMetadataAccess runtimeMetadata, IEnumerable`1 arguments)
    at Unity.IL2CPP.IntrinsicRemap.GetCustomArguments(ReadOnlyContext context, MethodReference methodToCall, MethodReference callingMethod, IRuntimeMetadataAccess runtimeMetadata, IEnumerable`1 arguments)
    at Unity.IL2CPP.MethodBodyWriter.TryWriteIntrinsicMethodCall(String returnVariable, IGeneratedMethodCodeWriter writer, MethodReference callingMethod, MethodReference unresolvedMethodToCall, MethodReference methodToCall, IRuntimeMetadataAccess runtimeMetadataAccess, IReadOnlyList`1 argumentArray, Boolean useArrayBoundsCheck)
    at Unity.IL2CPP.MethodWriter.<>c__DisplayClass7_0.<WriteAdjustorThunk>b__0(IGeneratedMethodCodeWriter bodyWriter, IRuntimeMetadataAccess metadataAccess)
    at Unity.IL2CPP.CodeWriters.CodeWriterExtensions.WriteMethodWithMetadataInitialization(IGeneratedMethodCodeWriter writer, String methodSignature, Action`2 writeMethodBody, String uniqueIdentifier, MethodReference methodRef, Boolean writingMethodBody)
    at Unity.IL2CPP.MethodWriter.WriteAdjustorThunk(MethodWriteContext context, IGeneratedMethodCodeWriter writer)
    at Unity.IL2CPP.SourceWriter.WriteType(SourceWritingContext context, IGeneratedMethodCodeWriter writer, TypeReference type, NPath filePath, Boolean writeMarshalingDefinitions)
    at Unity.IL2CPP.SourceWriters.SourceWriterBase`2.WriteItem(StreamWorkItemData`2 data)
    at Unity.IL2CPP.Contexts.Scheduling.Streams.FileLevelParallelStreamManager`3.WorkerWriteItemsToFile(WorkItemData`2 data)
    at Unity.IL2CPP.Contexts.Scheduling.PhaseWorkScheduler`1.WorkerLoop(Object data)
    Error: IL2CPP error for type 'System.Char' in assembly 'C:\Projects\Unity\Futuclass\futuclass\Futuclass\Library\Bee\artifacts\Android\ManagedStripped\mscorlib.dll'
    System.InvalidOperationException: Sequence contains no matching element
    at System.Linq.ThrowHelper.ThrowNoMatchException()
    at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source, Func`2 predicate)
    at Unity.IL2CPP.IntrinsicRemap.SpanGetItemArguments(ReadOnlyContext context, MethodReference callingMethod, MethodReference methodToCall, IRuntimeMetadataAccess runtimeMetadata, IEnumerable`1 arguments)
    at Unity.IL2CPP.IntrinsicRemap.GetCustomArguments(ReadOnlyContext context, MethodReference methodToCall, MethodReference callingMethod, IRuntimeMetadataAccess runtimeMetadata, IEnumerable`1 arguments)
    at Unity.IL2CPP.MethodBodyWriter.TryWriteIntrinsicMethodCall(String returnVariable, IGeneratedMethodCodeWriter writer, MethodReference callingMethod, MethodReference unresolvedMethodToCall, MethodReference methodToCall, IRuntimeMetadataAccess runtimeMetadataAccess, IReadOnlyList`1 argumentArray, Boolean useArrayBoundsCheck)
    at Unity.IL2CPP.MethodBodyWriter.TryWriteIntrinsicMethodCall(String returnVariable, MethodReference callingMethod, ResolvedMethodInfo methodToCall, IReadOnlyList`1 argumentArray)
    at Unity.IL2CPP.MethodBodyWriter.WriteCallExpressionFor(MethodReference callingMethod, ResolvedMethodInfo methodToCall, MethodCallType callType, List`1 argsFor, IMethodMetadataAccess methodMetadataAccess, Boolean emitNullCheckForInvocation)
    at Unity.IL2CPP.MethodBodyWriter.WriteCallExpressionFor(ResolvedMethodInfo methodToCall, MethodCallType callType, List`1 poppedValues, IMethodMetadataAccess methodMetadataAccess, Boolean emitNullCheckForInvocation)
    at Unity.IL2CPP.MethodBodyWriter.ProcessInstruction(Node node, InstructionBlock block, ResolvedInstruction ins)
    at Unity.IL2CPP.MethodBodyWriter.GenerateCodeRecursive(Node node, ReadOnlyDictionary`2 instructionBlocks)
    at Unity.IL2CPP.MethodBodyWriter.Generate()
    at Unity.IL2CPP.CodeWriters.CodeWriterExtensions.WriteMethodWithMetadataInitialization(IGeneratedMethodCodeWriter writer, String methodSignature, Action`2 writeMethodBody, String uniqueIdentifier, MethodReference methodRef, Boolean writingMethodBody)
    at Unity.IL2CPP.MethodWriter.WriteInlineMethodDefinition(MethodWriteContext context, IGeneratedMethodCodeWriter writer, MethodReference method, String usage)
    at Unity.IL2CPP.MethodWriter.WriteInlineMethodDefinitions(SourceWritingContext context, String usage, IGeneratedMethodCodeWriter writer)
    at Unity.IL2CPP.SourceWriters.SourceWriterBase`2.FlushStream(GlobalWriteContext context, IGeneratedMethodCodeStream stream, NPath filePath)
    at Unity.IL2CPP.Contexts.Scheduling.Streams.FileLevelParallelStreamManager`3.WorkerWriteItemsToFile(WorkItemData`2 data)
    at Unity.IL2CPP.Contexts.Scheduling.PhaseWorkScheduler`1.WorkerLoop(Object data)
    Error: IL2CPP error for type 'Futuclass.Game.TaskSystem.Answer' in C:/Projects/Unity/Futuclass/futuclass/Futuclass/Assets/_Futuclass/Scripts/Game/TaskSystem/Question.cs:24
    System.InvalidOperationException: Sequence contains no matching element
    at System.Linq.ThrowHelper.ThrowNoMatchException()
    at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source, Func`2 predicate)
    at Unity.IL2CPP.IntrinsicRemap.SpanGetItemArguments(ReadOnlyContext context, MethodReference callingMethod, MethodReference methodToCall, IRuntimeMetadataAccess runtimeMetadata, IEnumerable`1 arguments)
    at Unity.IL2CPP.IntrinsicRemap.GetCustomArguments(ReadOnlyContext context, MethodReference methodToCall, MethodReference callingMethod, IRuntimeMetadataAccess runtimeMetadata, IEnumerable`1 arguments)
    at Unity.IL2CPP.MethodBodyWriter.TryWriteIntrinsicMethodCall(String returnVariable, IGeneratedMethodCodeWriter writer, MethodReference callingMethod, MethodReference unresolvedMethodToCall, MethodReference methodToCall, IRuntimeMetadataAccess runtimeMetadataAccess, IReadOnlyList`1 argumentArray, Boolean useArrayBoundsCheck)
    at Unity.IL2CPP.MethodBodyWriter.TryWriteIntrinsicMethodCall(String returnVariable, MethodReference callingMethod, ResolvedMethodInfo methodToCall, IReadOnlyList`1 argumentArray)
    at Unity.IL2CPP.MethodBodyWriter.WriteCallExpressionFor(MethodReference callingMethod, ResolvedMethodInfo methodToCall, MethodCallType callType, List`1 argsFor, IMethodMetadataAccess methodMetadataAccess, Boolean emitNullCheckForInvocation)
    at Unity.IL2CPP.MethodBodyWriter.WriteCallExpressionFor(ResolvedMethodInfo methodToCall, MethodCallType callType, List`1 poppedValues, IMethodMetadataAccess methodMetadataAccess, Boolean emitNullCheckForInvocation)
    at Unity.IL2CPP.MethodBodyWriter.ProcessInstruction(Node node, InstructionBlock block, ResolvedInstruction ins)
    at Unity.IL2CPP.MethodBodyWriter.GenerateCodeRecursive(Node node, ReadOnlyDictionary`2 instructionBlocks)
    at Unity.IL2CPP.MethodBodyWriter.Generate()
    at Unity.IL2CPP.CodeWriters.CodeWriterExtensions.WriteMethodWithMetadataInitialization(IGeneratedMethodCodeWriter writer, String methodSignature, Action`2 writeMethodBody, String uniqueIdentifier, MethodReference methodRef, Boolean writingMethodBody)
    at Unity.IL2CPP.MethodWriter.WriteInlineMethodDefinition(MethodWriteContext context, IGeneratedMethodCodeWriter writer, MethodReference method, String usage)
    at Unity.IL2CPP.MethodWriter.WriteInlineMethodDefinitions(SourceWritingContext context, String usage, IGeneratedMethodCodeWriter writer)
    at Unity.IL2CPP.SourceWriters.SourceWriterBase`2.FlushStream(GlobalWriteContext context, IGeneratedMethodCodeStream stream, NPath filePath)
    at Unity.IL2CPP.Contexts.Scheduling.Streams.FileLevelParallelStreamManager`3.WorkerWriteItemsToFile(WorkItemData`2 data)
    at Unity.IL2CPP.Contexts.Scheduling.PhaseWorkScheduler`1.WorkerLoop(Object data)
    Error: IL2CPP error for method 'System.Boolean System.Text.Json.Serialization.Converters.DictionaryDefaultConverter`3::OnTryRead(System.Text.Json.Utf8JsonReader&,System.Type,System.Text.Json.JsonSerializerOptions,System.Text.Json.ReadStack&,TCollection&)' in assembly 'C:\Projects\Unity\Futuclass\futuclass\Futuclass\Library\Bee\artifacts\Android\ManagedStripped\System.Text.Json.dll'
    System.InvalidOperationException: Sequence contains no matching element
    at System.Linq.ThrowHelper.ThrowNoMatchException()
    at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source, Func`2 predicate)
    at Unity.IL2CPP.IntrinsicRemap.SpanGetItemArguments(ReadOnlyContext context, MethodReference callingMethod, MethodReference methodToCall, IRuntimeMetadataAccess runtimeMetadata, IEnumerable`1 arguments)
    at Unity.IL2CPP.IntrinsicRemap.GetCustomArguments(ReadOnlyContext context, MethodReference methodToCall, MethodReference callingMethod, IRuntimeMetadataAccess runtimeMetadata, IEnumerable`1 arguments)
    at Unity.IL2CPP.MethodBodyWriter.TryWriteIntrinsicMethodCall(String returnVariable, IGeneratedMethodCodeWriter writer, MethodReference callingMethod, MethodReference unresolvedMethodToCall, MethodReference methodToCall, IRuntimeMetadataAccess runtimeMetadataAccess, IReadOnlyList`1 argumentArray, Boolean useArrayBoundsCheck)
    at Unity.IL2CPP.MethodBodyWriter.TryWriteIntrinsicMethodCall(String returnVariable, MethodReference callingMethod, ResolvedMethodInfo methodToCall, IReadOnlyList`1 argumentArray)
    at Unity.IL2CPP.MethodBodyWriter.WriteCallExpressionFor(MethodReference callingMethod, ResolvedMethodInfo methodToCall, MethodCallType callType, List`1 argsFor, IMethodMetadataAccess methodMetadataAccess, Boolean emitNullCheckForInvocation)
    at Unity.IL2CPP.MethodBodyWriter.WriteCallExpressionFor(ResolvedMethodInfo methodToCall, MethodCallType callType, List`1 poppedValues, IMethodMetadataAccess methodMetadataAccess, Boolean emitNullCheckForInvocation)
    at Unity.IL2CPP.MethodBodyWriter.ProcessInstruction(Node node, InstructionBlock block, ResolvedInstruction ins)
    at Unity.IL2CPP.MethodBodyWriter.GenerateCodeRecursive(Node node, ReadOnlyDictionary`2 instructionBlocks)
    at Unity.IL2CPP.MethodBodyWriter.Generate()
    at Unity.IL2CPP.CodeWriters.CodeWriterExtensions.WriteMethodWithMetadataInitialization(IGeneratedMethodCodeWriter writer, String methodSignature, Action`2 writeMethodBody, String uniqueIdentifier, MethodReference methodRef, Boolean writingMethodBody)
    at Unity.IL2CPP.MethodWriter.WriteMethodDefinition(AssemblyWriteContext context, IGeneratedMethodCodeWriter writer, MethodReference method)
    at Unity.IL2CPP.SourceWriter.WriteType(SourceWritingContext context, IGeneratedMethodCodeWriter writer, TypeReference type, NPath filePath, Boolean writeMarshalingDefinitions)
    at Unity.IL2CPP.SourceWriters.SourceWriterBase`2.WriteItem(StreamWorkItemData`2 data)
    at Unity.IL2CPP.Contexts.Scheduling.Streams.FileLevelParallelStreamManager`3.WorkerWriteItemsToFile(WorkItemData`2 data)
    at Unity.IL2CPP.Contexts.Scheduling.PhaseWorkScheduler`1.WorkerLoop(Object data)
    Error: IL2CPP error for method 'System.Boolean System.Buffers.Text.Utf8Parser::TryParseAsSpecialFloatingPoint(System.ReadOnlySpan`1<System.Byte>,T,T,T,T&,System.Int32&)' in assembly 'C:\Projects\Unity\Futuclass\futuclass\Futuclass\Library\Bee\artifacts\Android\ManagedStripped\System.Memory.dll'
    System.InvalidOperationException: Sequence contains no matching element
    at System.Linq.ThrowHelper.ThrowNoMatchException()
    at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source, Func`2 predicate)
    at Unity.IL2CPP.IntrinsicRemap.SpanGetItem<message truncated>
     
    Last edited: Oct 22, 2021
  2. Wattosan

    Wattosan

    Joined:
    Mar 22, 2013
    Posts:
    460
    I failed to notice that one of the errors it has is related to one of our scripts:
    "
    Error: IL2CPP error for type 'Futuclass.Game.TaskSystem.Answer' in C:/Projects/Unity/Futuclass/futuclass/Futuclass/Assets/_Futuclass/Scripts/Game/TaskSystem/Question.cs:24
    System.InvalidOperationException: Sequence contains no matching element
    "

    The script looks like the following:
    Code (CSharp):
    1. using System;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.Localization;
    5.  
    6. namespace Futuclass.Game.TaskSystem
    7. {
    8.     [CreateAssetMenu(fileName = "Question", menuName = "Futuclass/Tasks/Question")]
    9.     public class Question : ScriptableObject
    10.     {
    11.         public LocalizedString LocalizedText;
    12.         public string Text;
    13.         public List<Answer> Answers = new List<Answer>();
    14.     }
    15.  
    16.     [Serializable]
    17.     public struct Answer
    18.     {
    19.         public LocalizedString LocalizedText;
    20.         public string Text;
    21.         public bool Correct;
    22.        
    23.         public Answer(LocalizedString localizedText, string text, bool correct)
    24.         {
    25.             LocalizedText = localizedText;
    26.             Text = text;
    27.             Correct = correct;
    28.         }
    29.     }
    30. }