IL2CPP Android build failing with Incremental Player Build failed

I’m having some problems with Android IL2CPP builds recently. I’m being able to perform IL2CPP builds successfully on my PC, but the same exact project is failing to build in a different PC with an error Incremental Player Build failed. I’ve read some reports of other people having problems similar to this as well. I even tried copying my library folder from my PC to the problematic PC but still have the same outcome. What am I doing wrong?

Unity 2021.2.13f1

1 Like

Can you provide the full text of the error message?

That I can! Here you go

C:\Program Files\Unity\Hub\Editor\2021.2.13f1\Editor\Data\il2cpp\build\deploy\il2cpp.exe @Library\Bee\artifacts\rsp\13470358729104072002.rsp
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(TypeDefinition definition)
at Unity.IL2CPP.DataModel.BuildLogic.TypeReferenceResolver.ResolveTypeReference(TypeReference typeReference, MappingContext mappingContext, CecilSourcedAssemblyData assembly)
at Unity.IL2CPP.DataModel.BuildLogic.TypeReferenceResolver.ResolveAssemblyTypeReferences(CecilSourcedAssemblyData assembly, ReadOnlyHashSet1 typeReferences, ReadOnlyHashSet1 genericInstances)
at Unity.IL2CPP.DataModel.BuildLogic.DataModelBuilder.<>c__DisplayClass14_0.b__0(CecilSourcedAssemblyData data)
at System.Threading.Tasks.Parallel.<>c__DisplayClass33_02.<ForEachWorker>b__0(Int32 i) at System.Threading.Tasks.Parallel.<>c__DisplayClass19_01.b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
— End of stack trace from previous location —
at System.Threading.Tasks.Parallel.<>c__DisplayClass19_01.<ForWorker>b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion) at System.Threading.Tasks.TaskReplicator.Replica1.ExecuteAction(Boolean& yieldedBeforeCompletion)
at System.Threading.Tasks.TaskReplicator.Replica.Execute()
— End of inner exception stack trace —
at System.Threading.Tasks.TaskReplicator.Run[TState](ReplicatableUserAction1 action, ParallelOptions options, Boolean stopOnFirstFailure) at System.Threading.Tasks.Parallel.ForWorker[TLocal](Int32 fromInclusive, Int32 toExclusive, ParallelOptions parallelOptions, Action1 body, Action2 bodyWithState, Func4 bodyWithLocal, Func1 localInit, Action1 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, Action1 body, Action2 bodyWithState, Func4 bodyWithLocal, Func1 localInit, Action1 localFinally) at System.Threading.Tasks.Parallel.ForEachWorker[TSource,TLocal](IList1 list, ParallelOptions parallelOptions, Action1 body, Action2 bodyWithState, Action3 bodyWithStateAndIndex, Func4 bodyWithStateAndLocal, Func5 bodyWithEverything, Func1 localInit, Action1 localFinally) at System.Threading.Tasks.Parallel.ForEachWorker[TSource,TLocal](IEnumerable1 source, ParallelOptions parallelOptions, Action1 body, Action2 bodyWithState, Action3 bodyWithStateAndIndex, Func4 bodyWithStateAndLocal, Func5 bodyWithEverything, Func1 localInit, Action1 localFinally) at System.Threading.Tasks.Parallel.ForEach[TSource](IEnumerable1 source, Action1 body) at Unity.IL2CPP.DataModel.BuildLogic.Utils.ParallelHelpers.ForEach[TSource](IEnumerable1 source, Action`1 func, Boolean enableSerial)
at Unity.IL2CPP.DataModel.BuildLogic.DataModelBuilder.Build()
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)
UnityEditor.GenericMenu:CatchMenu (object,string[ ],int)

1 Like

Thanks for the information. Can you submit a bug report for this issue? It looks like something we should investigate.

2 Likes

I will, is there an estimate as to when I could have a solution for this problem?

No, we will need to know more about the cause of the issue.

1 Like

I submitted the report, the title is the same as this thread

Any updates on this issue?

1 Like

I haven’t found any issue with this name. Could you post a link please?

About this issue. I receive same error after I added some nuget packages:

"Microsoft.Extensions.Configuration.FileExtensions": "3.0.3",
"Microsoft.Extensions.Configuration.Json": "3.0.3",
"Microsoft.Extensions.Configuration.CommandLine": "3.0.3",
"Microsoft.Extensions.Hosting": "3.0.3"

I use Unity 2021.2.3f1
Maybe this info helps.

I have the same problem.

@JoshPeterson Have you investigated this issue? It looks like a bug since ArgumentNullException should not be thrown, it should be prevented by some check.

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(TypeDefinition definition) in /Users/bokken/build/output/unity/il2cpp/Unity.IL2CPP.DataModel/TypeContext.cs:line 203
   at Unity.IL2CPP.DataModel.BuildLogic.TypeReferenceResolver.ResolveTypeReference(TypeReference typeReference, MappingContext mappingContext, CecilSourcedAssemblyData assembly) in /Users/bokken/build/output/unity/il2cpp/Unity.IL2CPP.DataModel/BuildLogic/TypeReferenceResolver.cs:line 118
   at Unity.IL2CPP.DataModel.BuildLogic.TypeReferenceResolver.ResolveAssemblyTypeReferences(CecilSourcedAssemblyData assembly, ReadOnlyHashSet`1 typeReferences, ReadOnlyHashSet`1 genericInstances) in /Users/bokken/build/output/unity/il2cpp/Unity.IL2CPP.DataModel/BuildLogic/TypeReferenceResolver.cs:line 47
   at Unity.IL2CPP.DataModel.BuildLogic.DataModelBuilder.<>c__DisplayClass14_0.<ResolveReferences>b__0(CecilSourcedAssemblyData data) in /Users/bokken/build/output/unity/il2cpp/Unity.IL2CPP.DataModel/BuildLogic/DataModelBuilder.cs:line 189
   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)

Unity Editor version: 2021.3.1f1 (3b70a0754835)

Could you please share a link to the ticket so that we could track status of this bug?

I don’t believe that we ever got a bug report for this issue. If we did, I can’t find the bug report number now.

@Qbit86 : Can you submit one?

https://fogbugz.unity3d.com/default.asp?1426932_ponvh8b68h1njhqg

3 Likes

This error happens to me after update 2018 project to 2021 Unity and update AdMob to latest 7.0.0
Before update AdMob all was fine, build works
I think deleting old GoogleMobileAds.Platforms.dll helps (it not used in new AdMob and left from old version)
(but maybe and some other old dlls)

It looks like this ArgumentNullException doesn’t reproduce anymore in 2021.3.4.
But now I encounter another problem: “LLVM ERROR: out of memory”.
It happens very often, after three hours of building (our game is huge) — but not always; sometimes build succeeds to finish after clean restart of the PC.
I have 32 Gb of memory on my working machine, and I have never had such an issue on Unity 2018 or 2020.

Building Library\Bee\artifacts\Android\iz17e\t8m6_-CSharp216.o failed with output:
LLVM ERROR: out of memory
Stack dump:
0.    Program arguments: C:/Program Files/Unity/Hub/Editor/2021.3.4f1/Editor/Data/PlaybackEngines/AndroidPlayer/NDK/toolchains/llvm/prebuilt/windows-x86_64/bin\clang++.exe ... C:/Viktor/.../Library/Bee/artifacts/Android/il2cppOutput/cpp/Assembly-CSharp216.cpp
1.    <eof> parser at end of file
2.    Code generation
3.    Running pass 'Function Pass Manager' on module 'C:/Viktor/.../Library/Bee/artifacts/Android/il2cppOutput/cpp/Assembly-CSharp216.cpp'.
4.    Running pass 'ARM Assembly Printer' on function '@U4E08U4E04U4E1BU4E0FU4E07U4E19U4E03U4E1AU4E12__ctor_m58980F2D02A3AA96A065D017FD9787387049D149'
#0 0x00007ff6e433fca6 C:\Program Files\Unity\Hub\Editor\2021.3.4f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe 0x4efca6 (C:\Program Files\Unity\Hub\Editor\2021.3.4f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe+0x4efca6)
#1 0x00007ff6e433fca6
#2 0x00007ff6e433fca6 (C:\Program Files\Unity\Hub\Editor\2021.3.4f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe+0x4efca6)
...
#13 0x00007ffda0121881 C:\Program Files\Unity\Hub\Editor\2021.3.4f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe 0x1395 C:\Program Files\Unity\Hub\Editor\2021.3.4f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe 0x14c8
#14 0x00007ffda0121881 (C:\WINDOWS\System32\ucrtbase.dll+0x71881)
#15 0x00007ffda0122851 (C:\WINDOWS\System32\ucrtbase.dll+0x72851)
0x00007FF6E433FCA6 (0x000097DFDBCE0E44 0x000000A8B45FBC54 0x0000000000000016 0x00007FF6E433FCA0)
0x00007FFDA0121881 (0x00007FF6E7DE2701 0x000000A800000000 0x0000000000000000 0x000000A8B45FBCF0), raise() + 0x1E1 bytes(s)
0x00007FFDA0122851 (0x0000000200000003 0x00007FF600000003 0x000000A8B45FBD10 0x000000024329A178), abort() + 0x31 bytes(s)
...
0x00007FFDA0DD7034 (0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000), BaseThreadInitThunk() + 0x14 bytes(s)
0x00007FFDA29E2651 (0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000), RtlUserThreadStart() + 0x21 bytes(s)
clang++: error: clang frontend command failed due to signal (use -v to see invocation)
Android (6454773 based on r365631c2) clang version 9.0.8 (https://android.googlesource.com/toolchain/llvm-project 98c855489587874b2a325e7a516b99d838599c6f) (based on LLVM 9.0.8svn)
Target: armv7a-unknown-linux-android22
Thread model: posix
InstalledDir: C:/Program Files/Unity/Hub/Editor/2021.3.4f1/Editor/Data/PlaybackEngines/AndroidPlayer/NDK/toolchains/llvm/prebuilt/windows-x86_64/bin
clang++: note: diagnostic msg: PLEASE submit a bug report to https://github.com/android-ndk/ndk/issues and include the crash backtrace, preprocessed source, and associated run script.
clang++: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang++: note: diagnostic msg: C:\Users\Victor\AppData\Local\Temp\Assembly-CSharp216-7e795e.cpp
clang++: note: diagnostic msg: C:\Users\Victor\AppData\Local\Temp\Assembly-CSharp216-7e795e.sh
clang++: note: diagnostic msg:

********************
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

This looks like an internal failure in the C++ compiler from the Android NDK. Do you know if the problem always happens in the same generated C++ method? In this error message, the method is U4E08U4E04U4E1BU4E0FU4E07U4E19U4E03U4E1AU4E12__ctor_m58980F2D02A3AA96A065D017FD9787387049D149, for example.

If we are lucky, it will happen in that method usually, and we can inspect the generated code for that method to better understand what might be the cause.

Alas, the error has occured again :frowning:
In 2021.3.5 on macOS, building for iOS.

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(TypeDefinition definition) in /Users/bokken/build/output/unity/il2cpp/Unity.IL2CPP.DataModel/TypeContext.cs:line 203
   at Unity.IL2CPP.DataModel.BuildLogic.TypeReferenceResolver.ResolveTypeReference(TypeReference typeReference, MappingContext mappingContext, CecilSourcedAssemblyData assembly) in /Users/bokken/build/output/unity/il2cpp/Unity.IL2CPP.DataModel/BuildLogic/TypeReferenceResolver.cs:line 118
   at Unity.IL2CPP.DataModel.BuildLogic.TypeReferenceResolver.ResolveAssemblyTypeReferences(CecilSourcedAssemblyData assembly, ReadOnlyHashSet`1 typeReferences, ReadOnlyHashSet`1 genericInstances) in /Users/bokken/build/output/unity/il2cpp/Unity.IL2CPP.DataModel/BuildLogic/TypeReferenceResolver.cs:line 47
   at Unity.IL2CPP.DataModel.BuildLogic.DataModelBuilder.<>c__DisplayClass14_0.<ResolveReferences>b__0(CecilSourcedAssemblyData data) in /Users/bokken/build/output/unity/il2cpp/Unity.IL2CPP.DataModel/BuildLogic/DataModelBuilder.cs:line 189
   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)
2 Likes

@JoshPeterson
If this issue [1] is related, could you please backport the fix to 2021.3.x?
[1] Unity Issue Tracker - Build fails with IL2CPP error when building in IL2CPP Scripting Backend

This does look very much like the issue you linked to. I’m trying to track down the fix for this issue to determine if we can back port it.

To make sure we have all of the details, can you submit a bug report for this issue against Unity 2021.3?

1 Like