Android build IL2CPP System.AggregateException: (Value cannot be null. (Parameter 'definition')

Hi,
When building for Android with IL2CPP I get errors.
Build with Mono works fine.
Could you please point me in the direction, of what could be wrong?
Or, if my assumptions are correct and sth is wrong with CognitoAuthentication.dll or any other dll, how to ‘reset’ DLL in the project?

Thanks in advance for help

C:\Program Files\Unity\Hub\Editor\2021.3.9f1\Editor\Data\il2cpp\build\deploy\il2cpp.exe --convert-to-cpp --assembly=Library/Bee/artifacts/Android/ManagedStripped/Amazon.Extensions.CognitoAuthentication.dll --assembly=Library/Bee/artifacts/Android/ManagedStripped/Assembly-CSharp.dll --assembly=Library/Bee/artifacts/Android/ManagedStripped/AWSSDK.CognitoIdentity.dll --assembly=Library/Bee/artifacts/Android/ManagedStripped/AWSSDK.CognitoIdentityProvider.dll --assembly=Library/Bee/artifacts/Android/ManagedStripped/AWSSDK.Core.dll --assembly=Library/Bee/artifacts/Android/ManagedStripped/AWSSDK.SecurityToken.dll --assembly=Library/Bee/artifacts/Android/ManagedStripped/Microsoft.Bcl.AsyncInterfaces.dll --assembly=Library/Bee/artifacts/Android/ManagedStripped/Mono.Security.dll --assembly=Library/Bee/artifacts/Android/ManagedStripped/mscorlib.dll --assembly=Library/Bee/artifacts/Android/ManagedStripped/Newtonsoft.Json.dll --assembly=Library/Bee/artifacts/Android/ManagedStripped/System.Configuration.dll --assembly=Library/Bee/artifacts/Android/ManagedStripped/System.Core.dll --assembly=Library/Bee/artifacts/Android/ManagedStripped/System.Data.dll --assembly=Library/Bee/artifacts/Android/ManagedStripped/System.dll --assembly=Library/Bee/artifacts/Android/ManagedStripped/System.Net.Http.dll --assembly=Library/Bee/artifacts/Android/ManagedStripped/System.Numerics.dll --assembly=Library/Bee/artifacts/Android/ManagedStripped/System.Runtime.Serialization.dll --assembly=Library/Bee/artifacts/Android/ManagedStripped/System.Xml.dll --assembly=Library/Bee/artifacts/Android/ManagedStripped/System.Xml.Linq.dll --assembly=Library/Bee/artifacts/Android/ManagedStripped/UniRx.dll --assembly=Library/Bee/artifacts/Android/ManagedStripped/Unity.Burst.dll --assembly=Library/Bee/artifacts/Android/ManagedStripped/Unity.Burst.Unsafe.dll --assembly=Library/Bee/artifacts/Android/ManagedStripped/Unity.Mathematics.dll --assembly=Library/Bee/artifacts/Android/ManagedStripped/Unity.RenderPipeline.Universal.ShaderLibrary.dll --assembly=Library/Bee/artifacts/Android/ManagedStripped/Unity.RenderPipelines.Core.Runtime.dll --assembly=Library/Bee/artifacts/Android/ManagedStripped/Unity.RenderPipelines.Universal.Runtime.dll --assembly=Library/Bee/artifacts/Android/ManagedStripped/Unity.TextMeshPro.dll --assembly=Library/Bee/artifacts/Android/ManagedStripped/UnityEngine.AndroidJNIModule.dll --assembly=Library/Bee/artifacts/Android/ManagedStripped/UnityEngine.AnimationModule.dll --assembly=Library/Bee/artifacts/Android/ManagedStripped/UnityEngine.AssetBundleModule.dll --assembly=Library/Bee/artifacts/Android/ManagedStripped/UnityEngine.AudioModule.dll --assembly=Library/Bee/artifacts/Android/ManagedStripped/UnityEngine.CoreModule.dll --assembly=Library/Bee/artifacts/Android/ManagedStripped/UnityEngine.dll --assembly=Library/Bee/artifacts/Android/ManagedStripped/UnityEngine.GridModule.dll --assembly=Library/Bee/artifacts/Android/ManagedStripped/UnityEngine.IMGUIModule.dll --assembly=Library/Bee/artifacts/Android/ManagedStripped/UnityEngine.InputLegacyModule.dll --assembly=Library/Bee/artifacts/Android/ManagedStripped/UnityEngine.InputModule.dll --assembly=Library/Bee/artifacts/Android/ManagedStripped/UnityEngine.JSONSerializeModule.dll --assembly=Library/Bee/artifacts/Android/ManagedStripped/UnityEngine.Physics2DModule.dll --assembly=Library/Bee/artifacts/Android/ManagedStripped/UnityEngine.PhysicsModule.dll --assembly=Library/Bee/artifacts/Android/ManagedStripped/UnityEngine.SharedInternalsModule.dll --assembly=Library/Bee/artifacts/Android/ManagedStripped/UnityEngine.SpriteShapeModule.dll --assembly=Library/Bee/artifacts/Android/ManagedStripped/UnityEngine.SubsystemsModule.dll --assembly=Library/Bee/artifacts/Android/ManagedStripped/UnityEngine.TextCoreFontEngineModule.dll --assembly=Library/Bee/artifacts/Android/ManagedStripped/UnityEngine.TextCoreTextEngineModule.dll --assembly=Library/Bee/artifacts/Android/ManagedStripped/UnityEngine.TextRenderingModule.dll --assembly=Library/Bee/artifacts/Android/ManagedStripped/UnityEngine.TilemapModule.dll --assembly=Library/Bee/artifacts/Android/ManagedStripped/UnityEngine.UI.dll --assembly=Library/Bee/artifacts/Android/ManagedStripped/UnityEngine.UIElementsModule.dll --assembly=Library/Bee/artifacts/Android/ManagedStripped/UnityEngine.UIElementsNativeModule.dll --assembly=Library/Bee/artifacts/Android/ManagedStripped/UnityEngine.UIModule.dll --assembly=Library/Bee/artifacts/Android/ManagedStripped/UnityEngine.UnityWebRequestAssetBundleModule.dll --assembly=Library/Bee/artifacts/Android/ManagedStripped/UnityEngine.UnityWebRequestModule.dll --assembly=Library/Bee/artifacts/Android/ManagedStripped/UnityEngine.UnityWebRequestWWWModule.dll --assembly=Library/Bee/artifacts/Android/ManagedStripped/UnityEngine.VRModule.dll --assembly=Library/Bee/artifacts/Android/ManagedStripped/UnityEngine.XRModule.dll --assembly=Library/Bee/artifacts/Android/ManagedStripped/Zenject-usage.dll --assembly=Library/Bee/artifacts/Android/ManagedStripped/Zenject.dll --data-folder=C:/Projects/relationship_place_unity/RelationshipPlacesUnity/Library/Bee/artifacts/Android/il2cppOutput/data --generatedcppdir=C:/Projects/relationship_place_unity/RelationshipPlacesUnity/Library/Bee/artifacts/Android/il2cppOutput/cpp --emit-null-checks --enable-array-bounds-check --generics-option=None,EnableFullSharing --dotnetprofile=unityaot-linux --profiler-report --profiler-output-file=C:/Projects/relationship_place_unity/RelationshipPlacesUnity/Library/Bee/artifacts/il2cpp_conv_0w5c.traceevents --print-command-line
Error: IL2CPP error (no further information about what managed code was being converted is available)
System.AggregateException: One or more errors occurred. (Value cannot be null. (Parameter 'definition'))
---> System.ArgumentNullException: Value cannot be null. (Parameter 'definition')
   at Unity.IL2CPP.DataModel.TypeContext.GetDef(MethodDefinition definition)
   at Unity.IL2CPP.DataModel.BuildLogic.MethodReferenceResolver.ResolveMethodReference(TypeContext context, UnderConstructionMethodReferenceRepository repository, CecilSourcedAssemblyData assemblyData, MethodReference methodReference, Dictionary`2 mapping)
   at Unity.IL2CPP.DataModel.BuildLogic.MethodReferenceResolver.ResolveAssemblyMethodReferences(TypeContext context, UnderConstructionMethodReferenceRepository repository, CecilSourcedAssemblyData assemblyDef, ReadOnlyHashSet`1 methodReferences)
   at Unity.IL2CPP.DataModel.BuildLogic.DataModelBuilder.<>c__DisplayClass15_0.<ResolveReferences>b__0(CecilSourcedAssemblyData data)
   at System.Threading.Tasks.Parallel.<>c__DisplayClass33_0`2.<ForEachWorker>b__0(Int32 i)
   at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`1.<ForWorker>b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
--- End of stack trace from previous location ---
   at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`1.<ForWorker>b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
   at System.Threading.Tasks.TaskReplicator.Replica`1.ExecuteAction(Boolean& yieldedBeforeCompletion)
   at System.Threading.Tasks.TaskReplicator.Replica.Execute()
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.TaskReplicator.Run[TState](ReplicatableUserAction`1 action, ParallelOptions options, Boolean stopOnFirstFailure)
   at System.Threading.Tasks.Parallel.ForWorker[TLocal](Int32 fromInclusive, Int32 toExclusive, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Func`4 bodyWithLocal, Func`1 localInit, Action`1 localFinally)
--- End of stack trace from previous location ---
   at System.Threading.Tasks.Parallel.ThrowSingleCancellationExceptionOrOtherException(ICollection exceptions, CancellationToken cancelToken, Exception otherException)
   at System.Threading.Tasks.Parallel.ForWorker[TLocal](Int32 fromInclusive, Int32 toExclusive, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Func`4 bodyWithLocal, Func`1 localInit, Action`1 localFinally)
   at System.Threading.Tasks.Parallel.ForEachWorker[TSource,TLocal](IList`1 list, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Action`3 bodyWithStateAndIndex, Func`4 bodyWithStateAndLocal, Func`5 bodyWithEverything, Func`1 localInit, Action`1 localFinally)
   at System.Threading.Tasks.Parallel.ForEachWorker[TSource,TLocal](IEnumerable`1 source, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Action`3 bodyWithStateAndIndex, Func`4 bodyWithStateAndLocal, Func`5 bodyWithEverything, Func`1 localInit, Action`1 localFinally)
   at System.Threading.Tasks.Parallel.ForEach[TSource](IEnumerable`1 source, Action`1 body)
   at Unity.IL2CPP.DataModel.BuildLogic.Utils.ParallelHelpers.ForEach[TSource](IEnumerable`1 source, Action`1 func, Boolean enableSerial)
   at Unity.IL2CPP.DataModel.BuildLogic.DataModelBuilder.Build()
   at Unity.IL2CPP.Contexts.Components.DataModelComponent.Load(LoadSettings loadSettings, Boolean ownsTypeContext, Boolean ownsBuilder, DataModelBuilder& builder)
   at Unity.IL2CPP.AssemblyConversion.Phases.InitializePhase.Run(AssemblyConversionContext context)
   at Unity.IL2CPP.AssemblyConversion.Classic.ClassicConverter.Run(AssemblyConversionContext context)
   at Unity.IL2CPP.AssemblyConversion.AssemblyConverter.ConvertAssemblies(AssemblyConversionInputData data, AssemblyConversionParameters parameters, AssemblyConversionInputDataForTopLevelAccess dataForTopLevel)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

We have seen this recently when aDLL is out of sync with the Unity Engine DLLs. Often running the Unity API updater will correct the issue. You can do this by re-importing all assets in the project. That will trigger the API updater to process all DLLs in the project.

1 Like

This does not resolve the issue for me. (I also have this issue on other platforms.)

Is it possible for you to submit a bug report that reproduces this issue? Maybe there is another case that I’m not aware of. Thanks!

I’ll see what I can do. Although the issue did just go away when I upgraded to Unity 2022.2.0b14.

I suspect that a type got stripped that shouldn’t have been, as reducing the managed stripping from High to Medium solved the issue. Maybe if I can run IL2CPP itself through the debugger it’ll help shed some light on the issue.