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. Dismiss Notice

Unity 2020 Android build fails with Code stripping, even empty one. Failed to link 'libunity.so'

Discussion in 'Android' started by msclower, Feb 23, 2022.

  1. msclower

    msclower

    Joined:
    May 26, 2017
    Posts:
    13
    Or course I could switch off code stripping (internet answer) but then my build goes from 23Mb to 28Mb. A tad annoying considering how long it took to get it down to 23Mb. I'm assuming it's an installation problem because an empty project build with stripping also fails with the same error. Maybe NDK related but out of my depth.

    Anyway the error message in build:

    Code (CSharp):
    1. C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/IDE/2020.3.25f1/Editor/Data/PlaybackEngines/AndroidPlayer/NDK/toolchains/llvm/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin\ld.gold.exe: error: cannot find -latomic
    2. clang++.exe: error: linker command failed with exit code 1 (use -v to see invocation)
    Code (CSharp):
    1. CommandInvokationFailure: Failed to link 'libunity.so'.
    2. C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/IDE/2020.3.25f1/Editor/Data/PlaybackEngines/AndroidPlayer/NDK/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe @"Temp/StagingArea/strip/armeabi-v7a/libunity.rsp"
    3.  
    4. stderr[
    5. C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/IDE/2020.3.25f1/Editor/Data/PlaybackEngines/AndroidPlayer/NDK/toolchains/llvm/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin\ld.gold.exe: error: cannot find -latomic
    6. clang++.exe: error: linker command failed with exit code 1 (use -v to see invocation)
    7. ]
    8. stdout[
    9.  
    10. ]
    11. exit code: 1
    12. UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <fc7be335e11c4872b360501993848bfb>:0)
    13. UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <fc7be335e11c4872b360501993848bfb>:0)
    14. UnityEditor.Android.Command.Run (System.String command, System.String args, System.String workingdir, System.String errorMsg) (at <fc7be335e11c4872b360501993848bfb>:0)
    15. UnityEditor.Android.PostProcessor.Tasks.BuildSharedLibrary.Link (UnityEditor.Android.PostProcessor.PostProcessorContext context, UnityEditor.Android.AndroidNDKTools ndk, UnityEditor.Android.AndroidTargetDeviceType deviceType, System.Collections.Generic.IEnumerable`1[T] objects) (at <fc7be335e11c4872b360501993848bfb>:0)
    16. UnityEditor.Android.PostProcessor.Tasks.BuildSharedLibrary.Build (UnityEditor.Android.PostProcessor.PostProcessorContext context, UnityEditor.Android.AndroidNDKTools ndk, UnityEditor.Android.AndroidTargetDeviceType deviceType) (at <fc7be335e11c4872b360501993848bfb>:0)
    17. UnityEditor.Android.PostProcessor.Tasks.BuildSharedLibrary.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <fc7be335e11c4872b360501993848bfb>:0)
    18. UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <fc7be335e11c4872b360501993848bfb>:0)
    19. Rethrow as BuildFailedException: Exception of type 'UnityEditor.Build.BuildFailedException' was thrown.
    20. UnityEditor.Android.PostProcessor.CancelPostProcess.AbortBuild (System.String title, System.String message, System.Exception ex) (at <fc7be335e11c4872b360501993848bfb>:0)
    21. UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <fc7be335e11c4872b360501993848bfb>:0)
    22. 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 <fc7be335e11c4872b360501993848bfb>:0)
    23. UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at <fc7be335e11c4872b360501993848bfb>:0)
    24. 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 <7ac35247888b44f4a7e290f1f6bb33f3>:0)
    25. UnityEditor.BuildPipeline:BuildPlayer(String[], String, BuildTarget, BuildOptions)
    26. TMAppProjectList:PerformPlatformBuild(BuildTargetGroup, BuildTarget, String[], String, BuildOptions) (at Assets/Editor/TMAppProjectList.cs:855)
    27. TMAppProjectList:BuildCurrent() (at Assets/Editor/TMAppProjectList.cs:690)
     
  2. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,663
    Your installation path is strange, it seems you have Unity installed inside a Visual Studio ? This makes paths inside NDK extremely long. On Windows there's this generic problem where if path is more than 260 symbols, some apps might start failing.
    I am not sure if that's what you're hitting, but I would recommend reinstalling Unity inside a shorter path, and definitely not inside Visual Studio installation path.
     
    msclower likes this.
  3. msclower

    msclower

    Joined:
    May 26, 2017
    Posts:
    13
    "Honey, I shrunk the bundle!". Thank you so much for your suggestion. It looks like that is exactly what the problem was. And my last problem left on my next release so very happy.
    It appears in 2019 when I upgraded from unity 2017 to 2018 that unity was first installed to the VS directory. No problems then, but at Christmas when I upgraded to Unity 2019 and then 2020, they used the same installation directory and the stripping stopped working.
     
    Tomas1856 likes this.