When I build a project,IL2CPP has an error

Thank you for your help me.

E:\Unity\6000.0.35f1\Editor\Data\il2cpp\build\deploy\il2cpp.exe @Library\Bee\artifacts\rsp\7099774068917591227.rsp
Error: IL2CPP error (no further information about what managed code was being converted is available)
System.AggregateException: One or more errors occurred. (Unresolved method reference : System.ReadOnlySpan`1<!0> System.ReadOnlySpan`1<System.Byte>::op_Implicit(!0[]))
 ---> System.ArgumentException: Unresolved method reference : System.ReadOnlySpan`1<!0> System.ReadOnlySpan`1<System.Byte>::op_Implicit(!0[])
   at Unity.IL2CPP.DataModel.TypeContext.GetDef(MethodReference) + 0xaa
   at Unity.IL2CPP.DataModel.BuildLogic.MethodReferenceResolver.ResolveMethodReference(TypeContext, UnderConstructionMethodReferenceRepository, CecilSourcedAssemblyData, MethodReference, Dictionary`2) + 0xf0
   at Unity.IL2CPP.DataModel.BuildLogic.MethodReferenceResolver.ResolveAssemblyMethodReferences(TypeContext, UnderConstructionMethodReferenceRepository, CecilSourcedAssemblyData, ReadOnlyHashSet`1) + 0xb6
   at Unity.IL2CPP.DataModel.BuildLogic.DataModelBuilder.<>c__DisplayClass16_0.<ResolveReferences>b__0(CecilSourcedAssemblyData data) + 0x193
   at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`1.<ForWorker>b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion) + 0x215
--- End of stack trace from previous location ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x20
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(Exception) + 0x13
   at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`1.<ForWorker>b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion) + 0x356
   at System.Threading.Tasks.TaskReplicator.Replica.Execute() + 0x3a
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.TaskReplicator.Run[TState](TaskReplicator.ReplicatableUserAction`1, ParallelOptions, Boolean) + 0x153
   at System.Threading.Tasks.Parallel.ForWorker[TLocal](Int32, Int32, ParallelOptions, Action`1, Action`2, Func`4, Func`1, Action`1) + 0x231
--- End of stack trace from previous location ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x20
   at System.Threading.Tasks.Parallel.ThrowSingleCancellationExceptionOrOtherException(ICollection, CancellationToken, Exception) + 0x31
   at System.Threading.Tasks.Parallel.ForWorker[TLocal](Int32, Int32, ParallelOptions, Action`1, Action`2, Func`4, Func`1, Action`1) + 0x37d
   at System.Threading.Tasks.Parallel.ForEachWorker[TSource, TLocal](IEnumerable`1, ParallelOptions, Action`1, Action`2, Action`3, Func`4, Func`5, Func`1, Action`1) + 0x116
   at System.Threading.Tasks.Parallel.ForEach[TSource](IEnumerable`1, Action`1) + 0x68
   at Unity.IL2CPP.DataModel.BuildLogic.Utils.ParallelHelpers.ForEach[TSource](IEnumerable`1, Action`1, Boolean) + 0x88
   at Unity.IL2CPP.DataModel.BuildLogic.DataModelBuilder.Build() + 0x22f
   at Unity.IL2CPP.AssemblyConversion.Phases.InitializePhase.Run(AssemblyConversionContext) + 0x319
   at Unity.IL2CPP.AssemblyConversion.Classic.ClassicConverter.Run(AssemblyConversionContext) + 0x11
   at Unity.IL2CPP.AssemblyConversion.AssemblyConverter.ConvertAssemblies(AssemblyConversionContext, ConversionMode) + 0x24
   at Unity.IL2CPP.AssemblyConversion.AssemblyConverter.ConvertAssemblies(TinyProfiler2, AssemblyConversionInputData, AssemblyConversionParameters, AssemblyConversionInputDataForTopLevelAccess) + 0x17f

UnityEditor.EditorApplication:Internal_CallDelayFunctions ()

You might try a reimport all, or perhaps delete the IL2CPP cache (See online for how).

More generallyā€¦

How to troubleshoot build failures:

Obviously, if there is actionable data, clues or information within any of the errors, fix those problems. Each error entry may have more information than can fit in the console log so select each error and read the expanded view below it.

If that gives you nothing worthwhile (look to Google! Youā€™re never the first one!), thenā€¦

First, make a blank project with a single blank scene and prove that it builds successfully.

If the blank project does NOT build, go fix your Unity installation or your other tools, such as Android SDK, NDK, JDK, etc. It may even be necessary to change to a different version of Unity3D. It is generally best to stay with LTS versions of Unity3D.

Until you can build a blank project to the target platform, donā€™t fiddle with anything else.

Once you can build a blank project, now bisect the problem by bringing over parts of your current project and building it one subsystem at a time, perhaps stubbing things out that might trigger compiler errors.

Most often things that prevent building are misconfigured or incorrectly-installed or incompatible third-party libraries such as Firebase or AdMob or IronSource.

Once you identify the subsystem, go to the documentation for it and make sure you are doing it correctly.

It may also be helpful to work through a tutorial or two for whatever subsystem is making the build fail.

Android build not building:

Circa July 2022 here have been reports of Unityā€™s installer failing to install the Android Tools.

Here was how I brought up Unity2020.3.41 and the Android SDK 31 on October 30, 2022 (edited on August 23, 2023 to include Android SDK 33ā€¦) (and again for SDK34):

Android Gradle errors and other related stuff:

Android SDK35 stuff:

1 Like

To be sure itā€™s not related to code stripping, set it to None in Player Settings. Since ReadOnlySpan is a commonly used type it should not be ā€œunresolvableā€.

Would also help to know what platform youā€™re building for.

1 Like