Search Unity

Question IL2CPP error building for Android upon upgrading to Unity 2020.2.2f1

Discussion in 'Android' started by DominatorDuck, Jan 26, 2021.

  1. DominatorDuck

    DominatorDuck

    Joined:
    Jan 8, 2013
    Posts:
    3
    After upgrading Unity from version 2020.1.11f1 to version 2020.2.2f1 we're unable to build our game for Android using the same assets, scripts and plugins.

    The error is the following:
    upload_2021-1-26_21-17-51.png

    This is the full reported exception from the editor:
    Code (CSharp):
    1. Exception: IL2CPP error (no further information about what managed code was being converted is available)
    2. Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
    3.    at Unity.Cecil.Awesome.AssemblyResolver.ResolveInternal(AssemblyNameReference name)
    4.    at Unity.Cecil.Awesome.AssemblyResolver.Resolve(AssemblyNameReference name)
    5.    at Unity.Cecil.Awesome.WindowsRuntimeAwareMetadataResolver.Resolve(TypeReference type)
    6.    at Mono.Cecil.Mixin.CheckedResolve(TypeReference self)
    7.    at Mono.Cecil.SignatureReader.ReadCustomAttributeEnum(TypeReference enum_type)
    8.    at Mono.Cecil.SignatureReader.ReadCustomAttributeElement(TypeReference type)
    9.    at Mono.Cecil.SignatureReader.ReadCustomAttributeNamedArgument(Collection`1& fields, Collection`1& properties)
    10.    at Mono.Cecil.SignatureReader.ReadCustomAttributeNamedArguments(UInt16 count, Collection`1& fields, Collection`1& properties)
    11.    at Mono.Cecil.SignatureReader.ReadSecurityAttribute()
    12.    at Mono.Cecil.MetadataReader.ReadSecurityDeclarationSignature(SecurityDeclaration declaration)
    13.    at Mono.Cecil.SecurityDeclaration.<Resolve>b__19_0(SecurityDeclaration declaration, MetadataReader reader)
    14.    at Mono.Cecil.ModuleDefinition.Read[TItem,TRet](TItem item, Func`3 read)
    15.    at Mono.Cecil.SecurityDeclaration.Resolve()
    16.    at Mono.Cecil.SecurityDeclaration.get_SecurityAttributes()
    17.    at Mono.Cecil.ImmediateModuleReader.ReadSecurityDeclarations(ISecurityDeclarationProvider provider)
    18.    at Mono.Cecil.ImmediateModuleReader.ReadMethods(TypeDefinition type)
    19.    at Mono.Cecil.ImmediateModuleReader.ReadType(TypeDefinition type)
    20.    at Mono.Cecil.ImmediateModuleReader.ReadTypes(Collection`1 types)
    21.    at Mono.Cecil.ImmediateModuleReader.ReadModule(ModuleDefinition module, Boolean resolve_attributes)
    22.    at Mono.Cecil.ImmediateModuleReader.<ReadModule>b__2_0(ModuleDefinition module, MetadataReader reader)
    23.    at Mono.Cecil.ModuleDefinition.Read[TItem,TRet](TItem item, Func`3 read)
    24.    at Mono.Cecil.ImmediateModuleReader.ReadModule()
    25.    at Mono.Cecil.ModuleReader.CreateModule(Image image, ReaderParameters parameters)
    26.    at Mono.Cecil.ModuleDefinition.ReadModule(String fileName, ReaderParameters parameters)
    27.    at Mono.Cecil.AssemblyDefinition.ReadAssembly(String fileName, ReaderParameters parameters)
    28.    at Unity.Cecil.Awesome.AssemblyLoader.Load(String name)
    29.    at System.Linq.Enumerable.SelectArrayIterator`2.MoveNext()
    30.    at System.Collections.Generic.HashSet`1.UnionWith(IEnumerable`1 other)
    31.    at System.Collections.Generic.HashSet`1..ctor(IEnumerable`1 collection, IEqualityComparer`1 comparer)
    32.    at Unity.IL2CPP.Common.AssemblyCollector.CollectAssembliesRecursive(IEnumerable`1 assemblies, IAssemblyLoader assemblyLoader, AssemblyDependenciesComponent assemblyDependencies)
    33.    at Unity.IL2CPP.Common.AssemblyCollector.CollectAssembliesToConvert(NPath[] assemblyPaths, IAssemblyLoader assemblyLoader, AssemblyDependenciesComponent assemblyDependencies)
    34.    at Unity.IL2CPP.AssemblyConversion.Phases.InitializePhase.Run(AssemblyConversionContext context)
    35.    at Unity.IL2CPP.AssemblyConversion.Classic.ClassicConverter.Run(AssemblyConversionContext context)
    36.    at Unity.IL2CPP.AssemblyConversion.AssemblyConverter.ConvertAssemblies(AssemblyConversionInputData data, AssemblyConversionParameters parameters, AssemblyConversionInputDataForTopLevelAccess dataForTopLevel)
    37. UnityEditorInternal.Runner.RunProgram (UnityEditor.Utils.Program p, System.String exe, System.String args, System.String workingDirectory, UnityEditor.Scripting.Compilers.CompilerOutputParserBase parser) (at <433cbae83977409887e43d50043210d2>:0)
    38. UnityEditorInternal.Runner.RunManagedProgram (System.String exe, System.String args, System.String workingDirectory, UnityEditor.Scripting.Compilers.CompilerOutputParserBase parser, System.Action`1[T] setupStartInfo) (at <433cbae83977409887e43d50043210d2>:0)
    39. UnityEditorInternal.IL2CPPBuilder.RunIl2CppWithArguments (System.Collections.Generic.List`1[T] arguments, System.Action`1[T] setupStartInfo, System.String generatedCppOutputDirectory) (at <433cbae83977409887e43d50043210d2>:0)
    40. UnityEditorInternal.IL2CPPBuilder.ConvertPlayerDlltoCpp (UnityEditor.Il2Cpp.Il2CppBuildPipelineData data, System.String outputDirectory, System.Boolean platformSupportsManagedDebugging) (at <433cbae83977409887e43d50043210d2>:0)
    41. UnityEditorInternal.IL2CPPBuilder.Run () (at <433cbae83977409887e43d50043210d2>:0)
    42. UnityEditorInternal.IL2CPPUtils.RunIl2Cpp (System.String tempFolder, System.String stagingAreaData, UnityEditorInternal.IIl2CppPlatformProvider platformProvider, System.Action`1[T] modifyOutputBeforeCompile, UnityEditor.RuntimeClassRegistry runtimeClassRegistry) (at <433cbae83977409887e43d50043210d2>:0)
    43. UnityEditor.Android.PostProcessor.Tasks.RunIl2Cpp.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <8554da968bee4c58879b31c6b5feb9f3>:0)
    44. UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <8554da968bee4c58879b31c6b5feb9f3>:0)
    45. 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 <8554da968bee4c58879b31c6b5feb9f3>:0)
    46. UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at <8554da968bee4c58879b31c6b5feb9f3>:0)
    47. 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 <433cbae83977409887e43d50043210d2>:0)
    48. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
    We're building using the following settings:
    • Backend: IL2CPP
    • API Level: .NET Standard 2.0
    • C++ Configuration: Release

    Android Settings:
    • Minimum API Level: 4.4 Kitkat (API level 19)
    • Target API Level: 10.0 Kitkat (API level 29)

    External tools:
    • OpenJDK 1.8.0_152 (comes with 2020.2.2f1 installation).
    • Custom Android SDK installation with the required API level 29 installed.
    • Android NDK that comes with 2020.2.2f1 installation.
    • Gradle 5.6.4 (comes with 2020.2.2f1 installation).

    Packages and plugins:
    Animancer 4.0 (Animancer.dll)
    MixPanel 2.1.4 (Mixpanel.dll)
    GooglePlayGames 0.10.11
    Cinemachine 2.6.3
    Mobile Notifications 1.3.2
    Post Processing 3.0.1
    Scriptable Build Pipeline 1.14.1
    Memory Profiler 0.2.8-preview.1
    Subsystem Registration 1.1.0
    Timeline 1.4.6
    Vector Graphics 2.0.0-preview.14
    TextMesh Pro 3.0.3​

    We used the same settings to build on 2020.1.11f1, and all of our managed plugins (assemblies) are built against .NET Standard 2.0.3.
    The IL2CPP exception does not give out much that we could use to puzzle out what went wrong, and the editor log does not contain any more information, other than the command being used while invoking il2cpp:

    Code (CSharp):
    1. Invoking il2cpp (via bee.exe) with arguments: --convert-to-cpp --emit-null-checks --enable-array-bounds-check --dotnetprofile="unityaot" --compile-cpp --libil2cpp-static --platform="Android" --architecture="ARMv7" --configuration="Release" --outputpath="[...]\libil2cpp.so" --cachedirectory="[...]/il2cpp_cache" --additional-include-directories=" [... (list of --additional-cpp files) ...]
    Is there anything we can do to get more information from IL2CPP?
    Has there been any other report related to IL2CPP problems after upgrading to 2020.2.2f1?
    Thanks for all the help and suggestions in advance.
     
  2. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    I've seen this error show up on the forums a few places, but we do not yet know the cause of it, and we cannot reproduce it on our end so far. Are you able to submit a bug report with a project that reproduces this issue?
     
  3. DominatorDuck

    DominatorDuck

    Joined:
    Jan 8, 2013
    Posts:
    3
    Thanks for answering, Josh.

    After doing lots of tests I narrowed the issue down to a particular package my project uses: Mixpanel.
    The issue is easy to reproduce with an empty Android project and MixPanel v2.2.2.

    I was gonna report this to MixPanel and send you guys the project to reproduce this, but after skimming their code I noticed this method that looked suspect:
    suspect.png

    The SecurityPermission attribute was the culprit, so I stopped having the IL2CPP error after commenting it.

    I'll report this to MixPanel, but of course if would be great if IL2CPP could better report what went wrong in this case. I was quite lucky to find the culprit, as you can imagine.
     
  4. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    Thanks for tracking this down! Can you still submit a bug report to Unity about this? At the very least, IL2CPP should report the problem much better (as you suggested). But I also wonder if this code should work.
     
  5. lyha

    lyha

    Joined:
    Feb 28, 2016
    Posts:
    15
    May you please share the Unity bug report link to track the progress?
    It looks like Mixpanel doesn't react to the reported issue. But it's the case either for 2020.3.9 version.
     
  6. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    We don't have a bug report for this issue yet. If you can reproduce it, we would love to get a bug report and have a look.