Search Unity

Question No ahead of time (AOT) code was generated issue in Unity 2020.3

Discussion in 'Android' started by MTeplytskyi, May 20, 2021.

  1. MTeplytskyi

    MTeplytskyi

    Joined:
    Jun 16, 2020
    Posts:
    26
    Hi! We tried to migrate to Unity version 2020.3.8 from 2019.4.18, but after update encountered an error connected with Zenject

    Code (CSharp):
    1. 2021.05.20 20:44:57.038 12605 12663 Error Unity ExecutionEngineException: Attempting to call method 'DGN.PRJX.Core.DialogManager`1[[DGN.PRJX.Game.UI.DialogID, DGN.PRJX, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]::.cctor' for which no ahead of time (AOT) code was generated.
    2. 2021.05.20 20:44:57.038 12605 12663 Error Unity   at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00000] in <00000000000000000000000000000000>:0
    3. 2021.05.20 20:44:57.038 12605 12663 Error Unity   at Zenject.ZenFactoryMethod.Invoke (System.Object[] args) [0x00000] in <00000000000000000000000000000000>:0
    4. 2021.05.20 20:44:57.038 12605 12663 Error Unity   at Zenject.DiContainer.InstantiateInternal (System.Type concreteType, System.Boolean autoInject, System.Collections.Generic.List`1[T] extraArgs, Zenject.InjectContext context, System.Object concreteIdentifier) [0x00000] in <00000000000000000000000000000000>:0
    5. 2021.05.20 20:44:57.038 12605 12663 Error Unity   at Zenject.TransientProvider.GetAllInstancesWithInjectSplit (Zenject.InjectContext context, System.Collections.Generic.List`1[T] args, System.Action& injectAction, System.Collections.Generic.List`1[T] buffer) [0x00000] in <00000000000000000000000000000000>:0
    6.  
    Dialogs manager class declared as
    Code (CSharp):
    1.     public class DialogManager<TEnum> : IDialogManager<TEnum>
    2.         where TEnum : Enum
    3. {
    4. ...
    5. }
    and it is binded in Zenject installer as
    Code (CSharp):
    1. Container.BindInterfacesTo<DialogManager<DialogID>>().AsSingle();
    where DialogID is Enum.

    To run the build in Unity 2020.3 we had to create next method
    Code (CSharp):
    1. public void UsedOnlyForAOTCodeGeneration()
    2.         {
    3.             // IL2CPP needs only this line.
    4.             new DialogManager<DialogID>();
    5.  
    6.             // Include an exception so we can be sure to know if this method is ever called.
    7.             throw new InvalidOperationException("This method is used for AOT code generation only. Do not call it at runtime.");
    8.         }
    Something changed in Unity 2020.3, but we didn't find any release notes that described changes in IL2CPP generation.
     
  2. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,931
    Can you submit a bug report for this issue? We did not expect a regression in this case in 2020.3, so we would like to investigate this.
     
  3. MTeplytskyi

    MTeplytskyi

    Joined:
    Jun 16, 2020
    Posts:
    26