Skip to content

Build Failing - Unity/Android - Null Reference Exception - Microsoft.Bcl.AsyncInterfaces.dll #1827

@RobBrooks

Description

@RobBrooks

Description

When attempting to build a Unity project targeting Android, the build fails with a null refrence exception.

Reproduction Steps

Scripting Backend - IL2CPP
Api Level - .Net 4.x

Stacktrace looks like this:


Exception: IL2CPP error for type 'System.Threading.Tasks.Sources.ManualResetValueTaskSourceCore`1' in assembly 'H:\Projects\MyProject\Temp\StagingArea\assets\bin\Data\Managed\Microsoft.Bcl.AsyncInterfaces.dll'
System.NullReferenceException: Object reference not set to an instance of an object.
   at Mono.Cecil.GenericInstanceType..ctor(TypeReference type)
   at Unity.IL2CPP.GenericsCollection.Inflater.ConstructGenericType(GenericContext context, TypeDefinition typeDefinition, IEnumerable`1 genericArguments)
   at Unity.IL2CPP.GenericsCollection.Inflater.InflateType(GenericContext context, GenericInstanceType genericInstanceType)
   at Unity.IL2CPP.GenericsCollection.Inflater.InflateType(GenericContext context, TypeReference typeReference)
   at Unity.IL2CPP.GenericsCollection.Inflater.ConstructGenericType(GenericContext context, TypeDefinition typeDefinition, IEnumerable`1 genericArguments)
   at Unity.IL2CPP.GenericsCollection.Inflater.InflateType(GenericContext context, GenericInstanceType genericInstanceType)
   at Unity.IL2CPP.GenericsCollection.GenericContextAwareVisitor.Visit(FieldReference fieldReference, Context context)
   at Unity.Cecil.Visitor.Visitor.Visit(Instruction instruction, Context context)
   at Unity.IL2CPP.GenericsCollection.GenericContextAwareVisitor.Visit(Instruction instruction, Context context)
   at Unity.Cecil.Visitor.Visitor.Visit(MethodBody methodBody, Context context)
   at Unity.Cecil.Visitor.Visitor.Visit(MethodDefinition methodDefinition, Context context)
   at Unity.IL2CPP.GenericsCollection.GenericContextAwareVisitor.Visit(MethodDefinition methodDefinition, Context context)
   at Unity.Cecil.Visitor.Visitor.Visit(TypeDefinition typeDefinition, Context context)
   at Unity.IL2CPP.GenericsCollection.GenericContextAwareVisitor.ProcessGenericType(PrimaryCollectionContext context, GenericInstanceType type, InflatedCollectionCollector generics, GenericInstanceMethod contextMethod)
   at Unity.IL2CPP.GenericsCollection.GenericContextAwareVisitor.Visit(FieldReference fieldReference, Context context)
   at Unity.Cecil.Visitor.Visitor.Visit(Instruction instruction, Context context)
   at Unity.IL2CPP.GenericsCollection.GenericContextAwareVisitor.Visit(Instruction instruction, Context context)
   at Unity.Cecil.Visitor.Visitor.Visit(MethodBody methodBody, Context context)
   at Unity.Cecil.Visitor.Visitor.Visit(MethodDefinition methodDefinition, Context context)
   at Unity.IL2CPP.GenericsCollection.GenericContextAwareVisitor.Visit(MethodDefinition methodDefinition, Context context)
   at Unity.Cecil.Visitor.Visitor.Visit(TypeDefinition typeDefinition, Context context)
   at Unity.IL2CPP.GenericsCollection.GenericContextAwareVisitor.ProcessGenericType(PrimaryCollectionContext context, GenericInstanceType type, InflatedCollectionCollector generics, GenericInstanceMethod contextMethod)
   at Unity.IL2CPP.GenericsCollection.GenericContextFreeVisitor.Visit(TypeDefinition typeDefinition, Context context)
   at Unity.Cecil.Visitor.Visitor.Visit(ModuleDefinition moduleDefinition, Context context)
   at Unity.Cecil.Visitor.Visitor.Visit(AssemblyDefinition assemblyDefinition, Context context)
   at Unity.IL2CPP.GenericsCollection.GenericsCollector.Collect(PrimaryCollectionContext context, ReadOnlyCollection`1 assemblies)
   at Unity.IL2CPP.AssemblyConversion.PrimaryCollection.Steps.Global.GenericsCollection.ProcessAllItems(GlobalPrimaryCollectionContext context, ReadOnlyCollection`1 items)
   at Unity.IL2CPP.AssemblyConversion.Steps.Base.GlobalScheduledStepFunc`3.WorkerWrapper(WorkItemData`3 workerData)
   at Unity.IL2CPP.Contexts.Scheduling.PhaseWorkScheduler`1.WorkerLoop(Object data)
UnityEditorInternal.Runner.RunProgram (UnityEditor.Utils.Program p, System.String exe, System.String args, System.String workingDirectory, UnityEditor.Scripting.Compilers.CompilerOutputParserBase parser) (at <c9b5231e365148a4bc210cc4e439206d>:0)
UnityEditorInternal.Runner.RunManagedProgram (System.String exe, System.String args, System.String workingDirectory, UnityEditor.Scripting.Compilers.CompilerOutputParserBase parser, System.Action`1[T] setupStartInfo) (at <c9b5231e365148a4bc210cc4e439206d>:0)
UnityEditorInternal.IL2CPPBuilder.RunIl2CppWithArguments (System.Collections.Generic.List`1[T] arguments, System.Action`1[T] setupStartInfo) (at <c9b5231e365148a4bc210cc4e439206d>:0)
UnityEditorInternal.IL2CPPBuilder.ConvertPlayerDlltoCpp (UnityEditor.Il2Cpp.Il2CppBuildPipelineData data) (at <c9b5231e365148a4bc210cc4e439206d>:0)
UnityEditorInternal.IL2CPPBuilder.Run () (at <c9b5231e365148a4bc210cc4e439206d>:0)
UnityEditorInternal.IL2CPPUtils.RunIl2Cpp (System.String tempFolder, System.String stagingAreaData, UnityEditorInternal.IIl2CppPlatformProvider platformProvider, System.Action`1[T] modifyOutputBeforeCompile, UnityEditor.RuntimeClassRegistry runtimeClassRegistry) (at <c9b5231e365148a4bc210cc4e439206d>:0)
UnityEditor.Android.PostProcessor.Tasks.RunIl2Cpp.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <2c6e9a95f1dd4e06ad71afcd2684dcb7>:0)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <2c6e9a95f1dd4e06ad71afcd2684dcb7>:0)
UnityEditor.Android.PostProcessAndroidPlayer.PostProcess (UnityEditor.BuildTarget target, System.String stagingAreaData, System.String stagingArea, System.String playerPackage, System.String installPath, System.String companyName, System.String productName, UnityEditor.BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report) (at <2c6e9a95f1dd4e06ad71afcd2684dcb7>:0)
UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at <2c6e9a95f1dd4e06ad71afcd2684dcb7>:0)
UnityEditor.PostprocessBuildPlayer.Postprocess (UnityEditor.BuildTargetGroup targetGroup, UnityEditor.BuildTarget target, System.String installPath, System.String companyName, System.String productName, System.Int32 width, System.Int32 height, UnityEditor.BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report) (at <c9b5231e365148a4bc210cc4e439206d>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

Included AWS Libraries


-a---- 07/04/2021 11:23 123904 AWSSDK.CognitoIdentity.dll
-a---- 07/04/2021 11:22 458752 AWSSDK.CognitoIdentityProvider.dll
-a---- 07/04/2021 11:20 1224704 AWSSDK.Core.dll
-a---- 07/04/2021 11:22 680960 AWSSDK.DynamoDBv2.dll
-a---- 07/04/2021 11:21 572928 AWSSDK.IdentityManagement.dll
-a---- 07/04/2021 11:21 322048 AWSSDK.Lambda.dll
-a---- 07/04/2021 11:20 740864 AWSSDK.S3.dll
-a---- 07/04/2021 11:20 75776 AWSSDK.SecurityToken.dll
-a---- 07/04/2021 11:20 148992 AWSSDK.SimpleNotificationService.dll
-a---- 07/04/2021 11:20 124928 AWSSDK.SQS.dll
-a---- 15/11/2019 08:36 21064 Microsoft.Bcl.AsyncInterfaces.dll
-a---- 18/09/2018 19:38 23600 System.Runtime.CompilerServices.Unsafe.dll
-a---- 29/11/2018 15:39 33008 System.Threading.Tasks.Extensions.dll

Environment

  • SDK Version: Using the zipfile assemblies from the following url:
  • Package Version: See below

https://docs.aws.amazon.com/sdk-for-net/v3/developer-guide/net-dg-install-assemblies.html#download-zip-files

Have tried using both aws-sdk-netstandard2.0.zip and aws-sdk-net45.zip; both give same issue.

  • OS Info: Windows 10
  • Build Environment Unity 2020.3.3f1
  • Targeted .NET Platform: Android 10

Resolution

  • 👋 I can/would-like-to implement a fix for this problem myself

Additional ( possibly superfluous ) Information

Due to one issue with the DynamoDB object persistence model in the original and now defunct AWS Unity SDK, I decided to 'do the right thing' and 'upgrade' to the active .NET project which I found does NOT support the calling conventions I was using in my project.
After making the necessary changes I figured I was there, only to discover this show-stopper.

Running the project in the editor seems mostly okay but making an Android build appears to not be happening at present so I think I'll return to the original SDK and try and fix the OPM issue I was having as I'm in a bit of a hurry to wrap things up.

In the meantime if anyone thinks this is worthy of attention, I'm more than happy to supply more details if required.


This is a 🐛 bug-report

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions