- Home /
Unity linker error for DLL in android build
Hello, I have an android project with a DLL, never had any problems and everything seemed to work. I wanted to obfuscate the DLL so I used ConfuserEx. The obfuscation seems to work when I tried to decompile it, and the game does work in the editor. But, when I tried to build an apk I got these errors(Using editor 2019.2.12f1):
1:
Failed running ...\2019.2.12f1\Editor\Data\il2cpp\build/UnityLinker.exe -out=.../Temp/StagingArea/assets/bin/Data/Managed/tempStrip -x=".../2019.2.12f1/Editor/Data/PlaybackEngines/AndroidPlayer/Whitelists/Core.xml" -x=.../Temp/StagingArea/assets/bin/Data/Managed/../platform_native_link.xml -x=.../AppData/Local/Temp/tmp1006393f.tmp -
x=.../AppData/Local/Temp/tmp453773c4.tmp -x=.../Temp/StagingArea/assets/bin/Data/Managed/TypesInScenes.xml -
x=...Assets/FacebookSDK/link.xml -
x=.../Assets/Firebase/Plugins/Crashlytics/link.xml -
d=.../Temp/StagingArea/assets/bin/Data/Managed --include-unity-root-assembly=.../Temp/StagingArea/assets/bin/Data/Managed/Assembly-CSharp.dll --include-unity-root-assembly=.../Temp/StagingArea/assets/bin/Data/Managed/UnityEngine.UI.dll --include-unity-root-assembly=.../Temp/StagingArea/assets/bin/Data/Managed/GoogleMobileAds.dll --include-unity-root-assembly=.../Temp/StagingArea/assets/bin/Data/Managed/com.unity.multiplayer-hlapi.Runtime.dll --include-unity-root-assembly=.../Temp/StagingArea/assets/bin/Data/Managed/DOTween.dll --include-unity-root-assembly=.../Temp/StagingArea/assets/bin/Data/Managed/Facebook.Unity.Settings.dll --include-unity-root-assembly=.../Temp/StagingArea/assets/bin/Data/Managed/TheLib.dll --dotnetruntime=il2cpp --dotnetprofile=unityaot --use-editor-options --include-directory=.../Temp/StagingArea/assets/bin/Data/Managed --rule-set=Conservative --editor-data-file=.../Temp/StagingArea/assets/bin/Data/Managed/EditorToUnityLinkerData.json --disable-engine-module-support --enable-engine-module-stripping --engine-stripping-flag=EnableUnityConnect --engine-modules-asset-file=".../2019.2.12f1/Editor/Data/PlaybackEngines/AndroidPlayer/Whitelists/../modules.asset"
stdout:
Fatal error in Unity CIL Linker
Mono.Linker.MarkException: Error processing method: 'System.Void _jdH6XFQzs1D68CySVxMYTrJdkXH`2::.ctor()' in assembly: 'TheLib.Sdk.dll' ---> Mono.Cecil.ResolutionException: Failed to resolve System.Collections.Generic.Dictionary`2<,> _jdH6XFQzs1D68CySVxMYTrJdkXH`2<,>::directionOut
at Mono.Linker.Steps.MarkStep.HandleUnresolvedField(FieldReference reference)
at Mono.Linker.Steps.MarkStep.MarkInstruction(Instruction instruction)
at Mono.Linker.Steps.MarkStep.MarkMethodBody(MethodBody body)
at Unity.Linker.Steps.UnityMarkStep.MarkMethodBody(MethodBody body)
at Mono.Linker.Steps.MarkStep.ProcessMethod(MethodDefinition method)
at Unity.Linker.Steps.UnityMarkStep.ProcessMethod(MethodDefinition method)
at Mono.Linker.Steps.MarkStep.ProcessQueue()
--- End of inner exception stack trace ---
at Mono.Linker.Steps.MarkStep.ProcessQueue()
at Mono.Linker.Steps.MarkStep.ProcessPrimaryQueue()
at Mono.Linker.Steps.MarkStep.Process()
at Unity.Linker.Steps.UnityMarkStep.Process(LinkContext context)
at Mono.Linker.Pipeline.ProcessStep(LinkContext context, IStep step)
at Unity.Linker.UnityPipeline.ProcessStep(LinkContext context, IStep step)
at Mono.Linker.Pipeline.Process(LinkContext context)
at Unity.Linker.UnityDriver.Run()
at Unity.Linker.UnityDriver.RunDriverWithoutErrorHandling()
at Unity.Linker.UnityDriver.RunDriver()
stderr:
UnityEngine.Debug:LogError(Object)
UnityEditorInternal.Runner:RunProgram(Program, String, String, String, CompilerOutputParserBase) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildUtils.cs:126)
UnityEditorInternal.Runner:RunManagedProgram(String, String, String, CompilerOutputParserBase, Action`1) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildUtils.cs:71)
UnityEditorInternal.AssemblyStripper:RunAssemblyLinker(IEnumerable`1, String&, String&, String, String) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/AssemblyStripper.cs:222)
UnityEditorInternal.AssemblyStripper:StripAssembliesTo(String[], String[], String, String, String&, String&, String, IIl2CppPlatformProvider, IEnumerable`1, BuildTargetGroup, ManagedStrippingLevel, Boolean, String) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/AssemblyStripper.cs:158)
UnityEditorInternal.AssemblyStripper:RunAssemblyStripper(IEnumerable, String, String[], String[], String, IIl2CppPlatformProvider, RuntimeClassRegistry, ManagedStrippingLevel) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/AssemblyStripper.cs:358)
UnityEditorInternal.AssemblyStripper:StripAssemblies(String, IIl2CppPlatformProvider, RuntimeClassRegistry, ManagedStrippingLevel) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/AssemblyStripper.cs:246)
UnityEditorInternal.IL2CPPBuilder:Run() (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:326)
UnityEditorInternal.IL2CPPUtils:RunIl2Cpp(String, String, IIl2CppPlatformProvider, Action`1, RuntimeClassRegistry) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:63)
UnityEngine.GUIUtility:processEvent(Int32, IntPtr) (at C:/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:179)
2:
Exception: ...\2019.2.12f1\Editor\Data\il2cpp\build/UnityLinker.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 C:/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildUtils.cs:128)
UnityEditorInternal.Runner.RunManagedProgram (System.String exe, System.String args, System.String workingDirectory, UnityEditor.Scripting.Compilers.CompilerOutputParserBase parser, System.Action`1[T] setupStartInfo) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildUtils.cs:71)
UnityEditorInternal.AssemblyStripper.RunAssemblyLinker (System.Collections.Generic.IEnumerable`1[T] args, System.String& out, System.String& err, System.String linkerPath, System.String workingDirectory) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/AssemblyStripper.cs:222)
UnityEditorInternal.AssemblyStripper.StripAssembliesTo (System.String[] assemblies, System.String[] searchDirs, System.String outputFolder, System.String workingDirectory, System.String& output, System.String& error, System.String linkerPath, UnityEditorInternal.IIl2CppPlatformProvider platformProvider, System.Collections.Generic.IEnumerable`1[T] additionalBlacklist, UnityEditor.BuildTargetGroup buildTargetGroup, UnityEditor.ManagedStrippingLevel managedStrippingLevel, System.Boolean stripEngineCode, System.String editorToLinkerDataPath) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/AssemblyStripper.cs:158)
UnityEditorInternal.AssemblyStripper.RunAssemblyStripper (System.Collections.IEnumerable assemblies, System.String managedAssemblyFolderPath, System.String[] assembliesToStrip, System.String[] searchDirs, System.String monoLinkerPath, UnityEditorInternal.IIl2CppPlatformProvider platformProvider, UnityEditor.RuntimeClassRegistry rcr, UnityEditor.ManagedStrippingLevel managedStrippingLevel) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/AssemblyStripper.cs:358)
UnityEditorInternal.AssemblyStripper.StripAssemblies (System.String managedAssemblyFolderPath, UnityEditorInternal.IIl2CppPlatformProvider platformProvider, UnityEditor.RuntimeClassRegistry rcr, UnityEditor.ManagedStrippingLevel managedStrippingLevel) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/AssemblyStripper.cs:246)
UnityEditorInternal.IL2CPPBuilder.Run () (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:326)
UnityEditorInternal.IL2CPPUtils.RunIl2Cpp (System.String tempFolder, System.String stagingAreaData, UnityEditorInternal.IIl2CppPlatformProvider platformProvider, System.Action`1[T] modifyOutputBeforeCompile, UnityEditor.RuntimeClassRegistry runtimeClassRegistry) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:63)
UnityEditor.Android.PostProcessor.Tasks.RunIl2Cpp.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <13e769c2760a442eaf6dff80696716f1>:0)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <13e769c2760a442eaf6dff80696716f1>: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 <13e769c2760a442eaf6dff80696716f1>:0)
UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at <13e769c2760a442eaf6dff80696716f1>: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 C:/buildslave/unity/build/Editor/Mono/BuildPipeline/PostprocessBuildPlayer.cs:281)
UnityEngine.GUIUtility:processEvent(Int32, IntPtr) (at C:/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:179)
I think the main part of the error is:
Fatal error in Unity CIL Linker
Mono.Linker.MarkException: Error processing method: 'System.Void _jdH6XFQzs1D68CySVxMYTrJdkXH`2::.ctor()' in assembly: 'TheLib.Sdk.dll' ---> Mono.Cecil.ResolutionException: Failed to resolve System.Collections.Generic.Dictionary`2<,> _jdH6XFQzs1D68CySVxMYTrJdkXH`2<,>::directionOut
I am not sure what in the obfuscation process cause it to fail, but if anyone have any experience with obfuscating DLLs in unity, especially with ConfuserEx, maybe you could help. Thanks.
Answer by jeeth_unity · Oct 01, 2021 at 03:36 AM
Hey @Sagief , Were you able to identify the problem yet, I a=have come across a similar issue. I have made my scripts into a dll as it contains the base features of my app. When I try to build an IL2CPP build with API compatibility 4.x it fails due to linker issue. I don't want to switch it to mono.
Your answer
Follow this Question
Related Questions
Practical Obfuscation Experience 3 Answers
Mach-O Linker error __Z21NotifyFramerateChangei 0 Answers
Apple Mach-O Linker(Id) Error when building Unity project 1 Answer
proguard obfuscation 0 Answers
I get this error some times when i build to android 1 Answer