Search Unity

Question Android IL2CPP build fails in 2021.2.0b15

Discussion in 'Android' 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. }
     
  3. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,918
    Could you delete <project>\Library\Bee folder and see if that makes any difference? 2021.2 introduced incremental build pipeline for Android, wondering if it's related
     
  4. Wattosan

    Wattosan

    Joined:
    Mar 22, 2013
    Posts:
    460
    It did not resolve the issue. I get the same error messages.
    Here's what some of the settings look like:
    upload_2021-10-22_15-20-6.png
    upload_2021-10-22_15-21-7.png
    upload_2021-10-22_15-21-26.png

    EDIT: I'm not sure why there are empty entries in the Preloaded Assets table. I've noticed this happened or a while now. I remove the empty entries and they're somehow added there again. But I guess it's not related.
     
    Last edited: Oct 22, 2021
  5. Wattosan

    Wattosan

    Joined:
    Mar 22, 2013
    Posts:
    460
    Are there some settings I can play around with?
     
  6. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,918
    Wattosan likes this.
  7. Wattosan

    Wattosan

    Joined:
    Mar 22, 2013
    Posts:
    460
  8. Wattosan

    Wattosan

    Joined:
    Mar 22, 2013
    Posts:
    460
    Tomas1856 likes this.