Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

IL2CPP build error on Android and iOS in 2019.3.1f, but no errors in 2019.2.1f1

Discussion in 'Android' started by Soulside, Feb 17, 2020.

  1. Soulside

    Soulside

    Joined:
    Nov 1, 2018
    Posts:
    30
    In our project we use the ElasticSearch .Net library.
    We have tested it for both platforms: Android and iOS using Unity 2019.2.1f1
    Now we try to switch to Unity 2019.3.1f1. If we compile the iOS project we get build errors:
    I was able to reproduce this error on empty project just with Elasticsearch.dll also for Android IL2CPP. (see attachment) This project compiles successfully for Android IL2CPP in Unity 2019.2.1f1, but does not compile in 2019.3.1f1

    Steps to reproduce:
    1. Open the project in Unity 2019.2.1f1
    2. Switch to Android
    3. Select IL2CPP Scripting backend in Player Settings
    4. Try to build
    5. See that the build was successful
    6. Close the project
    7. Delete all folders/files inside project folder except of Assets folder
    8. Open the project in Unity 2019.3.1f1
    9. Switch to Android
    10. Select IL2CPP Scripting backend in Player Settings
    11. Try to build
    12. See error message:
     

    Attached Files:

    MicahShaneTaylor likes this.
  2. Soulside

    Soulside

    Joined:
    Nov 1, 2018
    Posts:
    30
    Hello dear Unity team! This problem is still actual.
     
  3. MicahShaneTaylor

    MicahShaneTaylor

    Joined:
    Feb 18, 2020
    Posts:
    2
    I had a similar issue with the il2cpp.exe --convert-to-cpp --emit-null-checks --enable-array-bounds-check --dotnetprofile. Here is how I fixed the issue and got both an apk and appbundle to build (though this seems not to work for every project) ->

    -First, I changed the SDK and NDK locations - went to Edit->Preferences->uncheck the suggested unity path to both SDK and NDK and copy the file path where unity stores both of them.

    -paste a copy of both the sdk and NDK into your downloads folder on C drive

    -go back to Editor -> preferences-> Click browse next to sdk and ndk paths-> Navigate to a copy of both the SDK and NDK in C:\Users\yourUserName\Downloads\NDK and C:\Users\yourUserName\Downloads\sdk

    -Go to window->package manager and unistall/remove In-App purchases plugin.

    I have seen many people approach this problem in different ways on these forums, but this one worked for me.
    Best of luck. :)
     
  4. Soulside

    Soulside

    Joined:
    Nov 1, 2018
    Posts:
    30
    Hey, thanks for your answer. I tried it out, it does not help. :(

    I think the problem is in IL2CPP tool that comes with Unity 2019.3, not in the Android SDK or NDK. This is also actual for the iOS build.
    As we see from the log an unhandled exception occurs in the IL2CPP tool, it can not find a GetEnumerator() method in their internal dictionary for types.

    In the Elasticsearch.Net is a dictionary declaration:
    Code (CSharp):
    1. [JsonFormatter(typeof(DynamicDictionaryFormatter))]
    2. public class DynamicDictionary : DynamicObject, IEquatable<DynamicDictionary>, IEnumerable<string>, IEnumerable, IDictionary<string, DynamicValue>, ICollection<KeyValuePair<string, DynamicValue>>, IEnumerable<KeyValuePair<string, DynamicValue>>
    3. {
    4.     private readonly IDictionary<string, DynamicValue> _backingDictionary = new Dictionary<string, DynamicValue>(StringComparer.OrdinalIgnoreCase);
    5.     ...
    6.  
    7.     IEnumerator<KeyValuePair<string, DynamicValue>> IEnumerable<KeyValuePair<string, DynamicValue>>.GetEnumerator()
    8.     {
    9.         return _backingDictionary.GetEnumerator();
    10.     }
    11.     ...
    12. }
    The DynamicValue is a class that can be converted to pretty all C# types:
    Code (CSharp):
    1. public class DynamicValue : DynamicObject, IEquatable<DynamicValue>, IConvertible
    2. {
    3.     private readonly object _value;
    4.     ...
    5. }
    I have two copies of the test project attached to my previous post (zip file). One is opened in Unity 2019.2, another in Unity 2019.3.
    I've done all the steps described in my previous post. Now I compare IL2CPP output folders.
    So, if we compare the IL2CPP output folders (<project_folder>\Temp\StagingArea\Il2Cpp\il2cppOutput) in Unity 2019.2 and 2019.3 we see that the DynamicValue has no implementation in 2019.3 version.
    Here is Unity 2019.2 IL2CPP output (Elasticsearch.Net.cpp file):
    Code (CSharp):
    1. ...
    2. // Elasticsearch.Net.DynamicValue
    3. struct  DynamicValue_tF1C23C3A41C94C69BF21A2CC2B4409646107C876  : public DynamicObject_t61C899E96C95A40CEFBA36DE860005C26D12FBB0
    4. {
    5. public:
    6.     // System.Object Elasticsearch.Net.DynamicValue::_value
    7.     RuntimeObject * ____value_0;
    8.  
    9. public:
    10.     inline static int32_t get_offset_of__value_0() { return static_cast<int32_t>(offsetof(DynamicValue_tF1C23C3A41C94C69BF21A2CC2B4409646107C876, ____value_0)); }
    11.     inline RuntimeObject * get__value_0() const { return ____value_0; }
    12.     inline RuntimeObject ** get_address_of__value_0() { return &____value_0; }
    13.     inline void set__value_0(RuntimeObject * value)
    14.     {
    15.         ____value_0 = value;
    16.         Il2CppCodeGenWriteBarrier((void**)(&____value_0), (void*)value);
    17.     }
    18. };
    19. ...
    and here is the Unity 2019.3 IL2CPP output (Elasticsearch.Net.cpp file):
    Code (CSharp):
    1. ...
    2. // Elasticsearch.Net.DynamicValue
    3. struct  DynamicValue_tF1C23C3A41C94C69BF21A2CC2B4409646107C876  : public DynamicObject_t61C899E96C95A40CEFBA36DE860005C26D12FBB0
    4. {
    5. public:
    6.  
    7. public:
    8. };
    9. ...
    10.  
    if we keep comparing the files, we will see that there is no
    Code (CSharp):
    1.  
    2. DynamicDictionary_Equals_m7A79E3977FFE0AD9BE8933450848C15E8D078A5F,
    3. DynamicDictionary_Equals_m50FF6739CA43ED5E77D8BDD9E67B66D21E720DDD,
    4. DynamicDictionary_GetHashCode_m42EF3EACA354895E84815CD675C7C2AC81D08553,
    5. DynamicDictionary_GetNeutralKey_m3B3C34EB7A00B6398D292B406ED128FF5378C298
    methods implementation in the Unity 2019.3 version.

    It seems to me that something was changed in the IL2CPP tool, what breaks the build in Unity 2019.3 version. I assume that the problem is not only with the Elasticsearch dll, users can write own code that builds in Unity 2019.2 and does not build in 2019.3.

    This problem is still actual. Need help!
     
    MicahShaneTaylor likes this.
  5. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,789
    Can you submit a bug report for this issue? We would like to investigate it.
     
    MicahShaneTaylor likes this.
  6. Soulside

    Soulside

    Joined:
    Nov 1, 2018
    Posts:
    30
    Thanks for your reply! I've submitted a bug through Unity 2019.3.1f1 editor.
    (Case 1222808) IL2CPP build error on Android and iOS in 2019.3.1f, but no errors in 2019.2.1f1
     
    JoshPeterson likes this.
  7. Soulside

    Soulside

    Joined:
    Nov 1, 2018
    Posts:
    30
    I've installed Unity 2019.3.3f1 version and tried to build the sample project from my first message.
    It does not build.
    Here is the log message (looks pretty the same as in Unity 2019.3.1f1 version):
     
  8. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,789
    Thanks for the update. We've not corrected this issue yet.
     
    Soulside likes this.
  9. mygourabunity

    mygourabunity

    Joined:
    Nov 9, 2016
    Posts:
    4
    How to correct this issue?please tell me way to do this. I am really stuck here from a long time and still not able to build on Ill2cpp.
     
  10. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,789
    I'm not sure yet. It looks like our QA team closed the issue, but I think it might be a real problem that we should investigate. I've re-opened the issue and asked our QA team to have another look.
     
    Soulside and shanfinz like this.
  11. mygourabunity

    mygourabunity

    Joined:
    Nov 9, 2016
    Posts:
    4
    Thank you very much for drawing your attention to this. I am in real trouble for this, I am not able to get a build. Please tell me how can I get rid of this problem.
     
  12. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,789
    We will need to investigate it before I can offer any advice, sorry.
     
    shanfinz likes this.
  13. GSG1

    GSG1

    Joined:
    Dec 24, 2017
    Posts:
    1
    @JoshPeterson I'm having also this issue, I tried with 2019.3.07a and with 2019.4.1f1 and gives in both the same errors, I'll attach you the console, Im using default unity's NDK, SDK and JDK in a windows 10 PC:

    Failed running C:\Program Files\Unity\Hub\Editor\2019.4.1f1\Editor\Data\il2cpp/build/deploy/net471/il2cpp.exe --convert-to-cpp --emit-null-checks --enable-array-bounds-check --dotnetprofile="unityaot" --compile-cpp --libil2cpp-static --platform="Android" --architecture="ARMv7" --configuration="Release" --outputpath="D:\Unity\New Unity Project\Temp\StagingArea\assets\bin\Data\Native\armeabi-v7a\libil2cpp.so" --cachedirectory="D:\Unity\New Unity Project\Assets\..\Library\il2cpp_android_armeabi-v7a/il2cpp_cache" --additional-include-directories="C:/Program Files/Unity/Hub/Editor/2019.4.1f1/Editor/Data/PlaybackEngines/AndroidPlayer/Tools\bdwgc/include" --additional-include-directories="C:/Program Files/Unity/Hub/Editor/2019.4.1f1/Editor/Data/PlaybackEngines/AndroidPlayer/Tools\libil2cpp/include" --tool-chain-path="C:/Program Files/Unity/Hub/Editor/2019.4.1f1/Editor/Data/PlaybackEngines/AndroidPlayer/NDK" --profiler-report --map-file-parser="C:/Program Files/Unity/Hub/Editor/2019.4.1f1/Editor/Data/Tools/MapFileParser/MapFileParser.exe" --directory="D:/Unity/New Unity Project/Temp/StagingArea/assets/bin/Data/Managed" --generatedcppdir="D:/Unity/New Unity Project/Temp/StagingArea/Il2Cpp/il2cppOutput"

    stdout:
    Building libil2cpp.so with AndroidToolChain
    Output directory: D:\Unity\New Unity Project\Temp\StagingArea\assets\bin\Data\Native\armeabi-v7a
    Cache directory: D:\Unity\New Unity Project\Library\il2cpp_android_armeabi-v7a\il2cpp_cache
    ObjectFiles: 113 of which compiled: 113
    Time Compile: 10071 milliseconds Lump_libil2cpp_vm.cpp
    Time Compile: 8784 milliseconds mscorlib8.cpp
    Time Compile: 7746 milliseconds mscorlib7.cpp
    Time Compile: 6925 milliseconds UnityEngine.UI.cpp
    Time Compile: 6536 milliseconds Lump_libil2cpp_icalls.cpp
    Time Compile: 5388 milliseconds Il2CppTypeDefinitions.c
    Time Compile: 5262 milliseconds mscorlib3.cpp
    Time Compile: 4936 milliseconds Generics5.cpp
    Time Compile: 4732 milliseconds Generics1.cpp
    Time Compile: 4663 milliseconds Il2CppInvokerTable.cpp
    Total compilation time: 39738 milliseconds.
    il2cpp.exe didn't catch exception: Unity.IL2CPP.Building.BuilderFailedException: C:\Program Files\Unity\Hub\Editor\2019.4.1f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++ @"C:\Users\elnan\AppData\Local\Temp\tmp25F6.tmp" -o "D:\Unity\New Unity Project\Library\il2cpp_android_armeabi-v7a\il2cpp_cache\linkresult_E764FEB763DC20D759253AC330607842\libil2cpp.so" -shared -Wl,-soname,libil2cpp.so -Wl,--no-undefined -Wl,-z,noexecstack -Wl,--gc-sections -Wl,--build-id -stdlib=libc++ -static-libstdc++ -target armv7-linux-androideabi19 -Wl,--wrap,sigaction -llog -rdynamic -fuse-ld=gold.exe

    D:\Unity\New Unity Project\Temp\StagingArea\Il2Cpp\il2cppOutput/Assembly-CSharp.cpp:7328: error: undefined reference to 'SyncFiles'
    D:\Unity\New Unity Project\Temp\StagingArea\Il2Cpp\il2cppOutput/Assembly-CSharp.cpp:7342: error: undefined reference to 'WindowAlert'
    D:\Unity\New Unity Project\Temp\StagingArea\Il2Cpp\il2cppOutput/Assembly-CSharp.cpp:7328: error: undefined reference to 'SyncFiles'
    D:\Unity\New Unity Project\Temp\StagingArea\Il2Cpp\il2cppOutput/Assembly-CSharp.cpp:7342: error: undefined reference to 'WindowAlert'
    clang++.exe: error: linker command failed with exit code 1 (use -v to see invocation)


    en Unity.IL2CPP.Building.CppProgramBuilder.PostprocessObjectFiles(HashSet`1 objectFiles, CppToolChainContext toolChainContext)
    en Unity.IL2CPP.Building.CppProgramBuilder.Build(IBuildStatistics& statistics)
    en il2cpp.Program.DoRun(String[] args, List`1 foundAssemblies)
    en il2cpp.Program.Run(String[] args, Boolean setInvariantCulture)
    en il2cpp.Program.Main(String[] args)
    stderr:

    Excepci�n no controlada: Unity.IL2CPP.Building.BuilderFailedException: C:\Program Files\Unity\Hub\Editor\2019.4.1f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++ @"C:\Users\elnan\AppData\Local\Temp\tmp25F6.tmp" -o "D:\Unity\New Unity Project\Library\il2cpp_android_armeabi-v7a\il2cpp_cache\linkresult_E764FEB763DC20D759253AC330607842\libil2cpp.so" -shared -Wl,-soname,libil2cpp.so -Wl,--no-undefined -Wl,-z,noexecstack -Wl,--gc-sections -Wl,--build-id -stdlib=libc++ -static-libstdc++ -target armv7-linux-androideabi19 -Wl,--wrap,sigaction -llog -rdynamic -fuse-ld=gold.exe

    D:\Unity\New Unity Project\Temp\StagingArea\Il2Cpp\il2cppOutput/Assembly-CSharp.cpp:7328: error: undefined reference to 'SyncFiles'
    D:\Unity\New Unity Project\Temp\StagingArea\Il2Cpp\il2cppOutput/Assembly-CSharp.cpp:7342: error: undefined reference to 'WindowAlert'
    D:\Unity\New Unity Project\Temp\StagingArea\Il2Cpp\il2cppOutput/Assembly-CSharp.cpp:7328: error: undefined reference to 'SyncFiles'
    D:\Unity\New Unity Project\Temp\StagingArea\Il2Cpp\il2cppOutput/Assembly-CSharp.cpp:7342: error: undefined reference to 'WindowAlert'
    clang++.exe: error: linker command failed with exit code 1 (use -v to see invocation)


    en Unity.IL2CPP.Building.CppProgramBuilder.PostprocessObjectFiles(HashSet`1 objectFiles, CppToolChainContext toolChainContext)
    en Unity.IL2CPP.Building.CppProgramBuilder.Build(IBuildStatistics& statistics)
    en il2cpp.Program.DoRun(String[] args, List`1 foundAssemblies)
    en il2cpp.Program.Run(String[] args, Boolean setInvariantCulture)
    en il2cpp.Program.Main(String[] args)

    UnityEngine.Debug:LogError(Object)
    UnityEditorInternal.Runner:RunProgram(Program, String, String, String, CompilerOutputParserBase)
    UnityEditorInternal.Runner:RunManagedProgram(String, String, String, CompilerOutputParserBase, Action`1)
    UnityEditorInternal.IL2CPPBuilder:RunIl2CppWithArguments(List`1, Action`1, String)
    UnityEditorInternal.IL2CPPBuilder:ConvertPlayerDlltoCpp(Il2CppBuildPipelineData, String, String, Boolean)
    UnityEditorInternal.IL2CPPBuilder:Run()
    UnityEditorInternal.IL2CPPUtils:RunIl2Cpp(String, String, IIl2CppPlatformProvider, Action`1, RuntimeClassRegistry)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)

    2 console message:
    Exception: C:\Program Files\Unity\Hub\Editor\2019.4.1f1\Editor\Data\il2cpp/build/deploy/net471/il2cpp.exe did not run properly!
    UnityEditorInternal.Runner.RunProgram (UnityEditor.Utils.Program p, System.String exe, System.String args, System.String workingDirectory, UnityEditor.Scripting.Compilers.CompilerOutputParserBase parser) (at <a0a9ad37e16b4f7cb955e1101b72d4cc>:0)
    UnityEditorInternal.Runner.RunManagedProgram (System.String exe, System.String args, System.String workingDirectory, UnityEditor.Scripting.Compilers.CompilerOutputParserBase parser, System.Action`1[T] setupStartInfo) (at <a0a9ad37e16b4f7cb955e1101b72d4cc>:0)
    UnityEditorInternal.IL2CPPBuilder.RunIl2CppWithArguments (System.Collections.Generic.List`1[T] arguments, System.Action`1[T] setupStartInfo, System.String workingDirectory) (at <a0a9ad37e16b4f7cb955e1101b72d4cc>:0)
    UnityEditorInternal.IL2CPPBuilder.ConvertPlayerDlltoCpp (UnityEditor.Il2Cpp.Il2CppBuildPipelineData data, System.String outputDirectory, System.String workingDirectory, System.Boolean platformSupportsManagedDebugging) (at <a0a9ad37e16b4f7cb955e1101b72d4cc>:0)
    UnityEditorInternal.IL2CPPBuilder.Run () (at <a0a9ad37e16b4f7cb955e1101b72d4cc>:0)
    UnityEditorInternal.IL2CPPUtils.RunIl2Cpp (System.String tempFolder, System.String stagingAreaData, UnityEditorInternal.IIl2CppPlatformProvider platformProvider, System.Action`1[T] modifyOutputBeforeCompile, UnityEditor.RuntimeClassRegistry runtimeClassRegistry) (at <a0a9ad37e16b4f7cb955e1101b72d4cc>:0)
    UnityEditor.Android.PostProcessor.Tasks.RunIl2Cpp.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <d7067458867d436a825598eb5e44cdf0>:0)
    UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <d7067458867d436a825598eb5e44cdf0>: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 <d7067458867d436a825598eb5e44cdf0>:0)
    UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at <d7067458867d436a825598eb5e44cdf0>: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 <a0a9ad37e16b4f7cb955e1101b72d4cc>:0)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)

    Last message:
    UnityEditor.BuildPlayerWindow+BuildMethodException: 3 errors
    at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x002bb] in <a0a9ad37e16b4f7cb955e1101b72d4cc>:0
    at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x00080] in <a0a9ad37e16b4f7cb955e1101b72d4cc>:0
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)
     
  14. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,789
    This failure occurs because the code in the project has extern methods in C#. Methods marked as extern with a the [Dllimport("__Internal")] attribute must be present in a native library that is linked with the Unity player when building with the IL2CPP scripting backend.

    For example, this in this project one function which causes this issue is named: SyncFiles

    You have two options:

    1. Build a native library with all of the methods marked as extern with the [Dllimport("__Internal")] attribute for the target platform and architecture of the player. See this documentation for details about native plugins: https://docs.unity3d.com/Manual/NativePlugins.html

    2. Remove the C# code which defines this extern method. You can do that with platform dependent compilation: https://docs.unity3d.com/Manual/PlatformDependentCompilation.html