Search Unity

Android builds failing when 'Script Debugging' is enabled

Discussion in 'Editor & General Support' started by notSimon, Dec 23, 2020.

  1. notSimon

    notSimon

    Joined:
    Feb 19, 2018
    Posts:
    4
    I've been struggling building for Android for a while and have narrowed things down somewhat but am stuck again and am not able to make any more progress.

    Building without 'Development Build' checked: works fine and the game runs.

    Building with 'Development Build' checked: the game freezes right after the splash screen.

    Building with 'Development Build' + 'Script Debugging': build fails with the following error:

    Edit: I forgot to say that this happens in both local and cloud builds

    Edit 2: Also forgot to say that I'm running 2019.4.16f

    Exception: C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\il2cpp/build/deploy/net471/il2cpp.exe did not run properly!

    Failed running "C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\il2cpp/build/deploy/net471/il2cpp.exe" --compile-cpp --libil2cpp-static --platform="Android" --architecture="ARM64" --configuration="ReleasePlus" --outputpath="C:\Users\simon\repos\rugby-unity\Temp\StagingArea\assets\bin\Data\Native\arm64-v8a\libil2cpp.so" --cachedirectory="C:\Users\simon\repos\rugby-unity\Assets\..\Library\il2cpp_android_arm64-v8a/il2cpp_cache" --additional-include-directories="C:/Program Files/Unity/Hub/Editor/2019.4.16f1/Editor/Data/PlaybackEngines/AndroidPlayer/Tools\bdwgc/include" --additional-include-directories="C:/Program Files/Unity/Hub/Editor/2019.4.16f1/Editor/Data/PlaybackEngines/AndroidPlayer/Tools\libil2cpp/include" --tool-chain-path="C:/Program Files/Unity/Hub/Editor/2019.4.16f1/Editor/Data/PlaybackEngines/AndroidPlayer/NDK" --map-file-parser="C:/Program Files/Unity/Hub/Editor/2019.4.16f1/Editor/Data/Tools/MapFileParser/MapFileParser.exe" --generatedcppdir=C:/Users/simon/repos/rugby-unity/Temp/StagingArea/Il2Cpp/il2cppOutput --dotnetprofile="unityaot" --enable-debugger

    stdout:
    Building libil2cpp.so with AndroidToolChain
    Output directory: C:\Users\simon\repos\rugby-unity\Temp\StagingArea\assets\bin\Data\Native\arm64-v8a
    Cache directory: C:\Users\simon\repos\rugby-unity\Library\il2cpp_android_arm64-v8a\il2cpp_cache
    ObjectFiles: 994 of which compiled: 0
    Total compilation time: 935 milliseconds.
    il2cpp.exe didn't catch exception: Unity.IL2CPP.Building.BuilderFailedException: C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++ @"C:\Users\simon\AppData\Local\Temp\tmpBC36.tmp" -o "C:\Users\simon\repos\rugby-unity\Library\il2cpp_android_arm64-v8a\il2cpp_cache\linkresult_B7315E624227AAD87D98CA3B0A62996F\libil2cpp.so" -shared -Wl,-soname,libil2cpp.so -Wl,--no-undefined -Wl,-z,noexecstack -Wl,--gc-sections -Wl,--build-id -stdlib=libc++ -static-libstdc++ -target aarch64-linux-android21 -Wl,--wrap,sigaction -llog -rdynamic -fuse-ld=bfd.exe

    C:/Users/simon/repos/rugby-unity/Library/il2cpp_android_arm64-v8a/il2cpp_cache/libil2cpp/DBC5130846C16018DCB65FE676D3FFB2.o: In function `AndroidLogCallback(char const*)':
    C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\il2cpp\libil2cpp\os\Android/Initialize.cpp:12:(.text._ZL18AndroidLogCallbackPKc+0x18): relocation truncated to fit: R_AARCH64_JUMP26 against symbol `__android_log_print' defined in .text section in C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/../sysroot/usr/lib/aarch64-linux-android/21/liblog.so
    C:/Users/simon/repos/rugby-unity/Library/il2cpp_android_arm64-v8a/il2cpp_cache/libil2cpp/DBC5130846C16018DCB65FE676D3FFB2.o: In function `il2cpp::eek:s::OpenAndroidConfig()':
    C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\il2cpp\libil2cpp\os\Android/TimeZoneInfo.cpp:48:(.text._ZN6il2cpp2os17OpenAndroidConfigEv+0x1c): relocation truncated to fit: R_AARCH64_CALL26 against symbol `getenv@@LIBC' defined in .text section in C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/../sysroot/usr/lib/aarch64-linux-android/21/libc.so
    C:/Users/simon/repos/rugby-unity/Library/il2cpp_android_arm64-v8a/il2cpp_cache/libil2cpp/DBC5130846C16018DCB65FE676D3FFB2.o: In function `std::__ndk1::char_traits<char>::length(char const*)':
    C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/../sysroot/usr/include/c++/v1/__string:217:(.text._ZN6il2cpp2os17OpenAndroidConfigEv+0x50): relocation truncated to fit: R_AARCH64_CALL26 against symbol `strlen@@LIBC' defined in .text section in C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/../sysroot/usr/lib/aarch64-linux-android/21/libc.so
    C:/Users/simon/repos/rugby-unity/Library/il2cpp_android_arm64-v8a/il2cpp_cache/libil2cpp/DBC5130846C16018DCB65FE676D3FFB2.o: In function `il2cpp::eek:s::OpenAndroidConfig()':
    C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\il2cpp\libil2cpp\os\Android/TimeZoneInfo.cpp:49:(.text._ZN6il2cpp2os17OpenAndroidConfigEv+0x88): relocation truncated to fit: R_AARCH64_CALL26 against symbol `getenv@@LIBC' defined in .text section in C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/../sysroot/usr/lib/aarch64-linux-android/21/libc.so
    C:/Users/simon/repos/rugby-unity/Library/il2cpp_android_arm64-v8a/il2cpp_cache/libil2cpp/DBC5130846C16018DCB65FE676D3FFB2.o: In function `std::__ndk1::__libcpp_allocate(unsigned long, unsigned long)':
    C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/../sysroot/usr/include/c++/v1/new:259:(.text._ZN6il2cpp2os17OpenAndroidConfigEv+0x9c): relocation truncated to fit: R_AARCH64_CALL26 against symbol `operator new(unsigned long)' defined in .text._Znwm section in C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/../sysroot/usr/lib/aarch64-linux-android\libc++_static.a(new.o)
    C:/Users/simon/repos/rugby-unity/Library/il2cpp_android_arm64-v8a/il2cpp_cache/libil2cpp/DBC5130846C16018DCB65FE676D3FFB2.o: In function `std::__ndk1::char_traits<char>::length(char const*)':
    C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/../sysroot/usr/include/c++/v1/__string:217:(.text._ZN6il2cpp2os17OpenAndroidConfigEv+0xd0): relocation truncated to fit: R_AARCH64_CALL26 against symbol `strlen@@LIBC' defined in .text section in C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/../sysroot/usr/lib/aarch64-linux-android/21/libc.so
    C:/Users/simon/repos/rugby-unity/Library/il2cpp_android_arm64-v8a/il2cpp_cache/libil2cpp/DBC5130846C16018DCB65FE676D3FFB2.o: In function `std::__ndk1::_DeallocateCaller::__do_call(void*)':
    C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/../sysroot/usr/include/c++/v1/new:340:(.text._ZN6il2cpp2os17OpenAndroidConfigEv+0x114): relocation truncated to fit: R_AARCH64_CALL26 against symbol `operator delete(void*)' defined in .text._ZdlPv section in C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/../sysroot/usr/lib/aarch64-linux-android\libc++_static.a(new.o)
    C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/../sysroot/usr/include/c++/v1/new:340:(.text._ZN6il2cpp2os17OpenAndroidConfigEv+0x124): relocation truncated to fit: R_AARCH64_CALL26 against symbol `operator delete(void*)' defined in .text._ZdlPv section in C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/../sysroot/usr/lib/aarch64-linux-android\libc++_static.a(new.o)
    C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/../sysroot/usr/include/c++/v1/new:340:(.text._ZN6il2cpp2os17OpenAndroidConfigEv+0x18c): relocation truncated to fit: R_AARCH64_CALL26 against symbol `operator delete(void*)' defined in .text._ZdlPv section in C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/../sysroot/usr/lib/aarch64-linux-android\libc++_static.a(new.o)
    C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/../sysroot/usr/include/c++/v1/new:340:(.text._ZN6il2cpp2os17OpenAndroidConfigEv+0x1c4): relocation truncated to fit: R_AARCH64_CALL26 against symbol `operator delete(void*)' defined in .text._ZdlPv section in C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/../sysroot/usr/lib/aarch64-linux-android\libc++_static.a(new.o)
    C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/../sysroot/usr/include/c++/v1/new:340:(.text._ZN6il2cpp2os17OpenAndroidConfigEv+0x1ec): additional relocation overflows omitted from the output
    clang++.exe: error: linker command failed with exit code 1 (use -v to see invocation)


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

    Unhandled Exception: Unity.IL2CPP.Building.BuilderFailedException: C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++ @"C:\Users\simon\AppData\Local\Temp\tmpBC36.tmp" -o "C:\Users\simon\repos\rugby-unity\Library\il2cpp_android_arm64-v8a\il2cpp_cache\linkresult_B7315E624227AAD87D98CA3B0A62996F\libil2cpp.so" -shared -Wl,-soname,libil2cpp.so -Wl,--no-undefined -Wl,-z,noexecstack -Wl,--gc-sections -Wl,--build-id -stdlib=libc++ -static-libstdc++ -target aarch64-linux-android21 -Wl,--wrap,sigaction -llog -rdynamic -fuse-ld=bfd.exe

    C:/Users/simon/repos/rugby-unity/Library/il2cpp_android_arm64-v8a/il2cpp_cache/libil2cpp/DBC5130846C16018DCB65FE676D3FFB2.o: In function `AndroidLogCallback(char const*)':
    C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\il2cpp\libil2cpp\os\Android/Initialize.cpp:12:(.text._ZL18AndroidLogCallbackPKc+0x18): relocation truncated to fit: R_AARCH64_JUMP26 against symbol `__android_log_print' defined in .text section in C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/../sysroot/usr/lib/aarch64-linux-android/21/liblog.so
    C:/Users/simon/repos/rugby-unity/Library/il2cpp_android_arm64-v8a/il2cpp_cache/libil2cpp/DBC5130846C16018DCB65FE676D3FFB2.o: In function `il2cpp::eek:s::OpenAndroidConfig()':
    C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\il2cpp\libil2cpp\os\Android/TimeZoneInfo.cpp:48:(.text._ZN6il2cpp2os17OpenAndroidConfigEv+0x1c): relocation truncated to fit: R_AARCH64_CALL26 against symbol `getenv@@LIBC' defined in .text section in C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/../sysroot/usr/lib/aarch64-linux-android/21/libc.so
    C:/Users/simon/repos/rugby-unity/Library/il2cpp_android_arm64-v8a/il2cpp_cache/libil2cpp/DBC5130846C16018DCB65FE676D3FFB2.o: In function `std::__ndk1::char_traits<char>::length(char const*)':
    C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/../sysroot/usr/include/c++/v1/__string:217:(.text._ZN6il2cpp2os17OpenAndroidConfigEv+0x50): relocation truncated to fit: R_AARCH64_CALL26 against symbol `strlen@@LIBC' defined in .text section in C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/../sysroot/usr/lib/aarch64-linux-android/21/libc.so
    C:/Users/simon/repos/rugby-unity/Library/il2cpp_android_arm64-v8a/il2cpp_cache/libil2cpp/DBC5130846C16018DCB65FE676D3FFB2.o: In function `il2cpp::eek:s::OpenAndroidConfig()':
    C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\il2cpp\libil2cpp\os\Android/TimeZoneInfo.cpp:49:(.text._ZN6il2cpp2os17OpenAndroidConfigEv+0x88): relocation truncated to fit: R_AARCH64_CALL26 against symbol `getenv@@LIBC' defined in .text section in C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/../sysroot/usr/lib/aarch64-linux-android/21/libc.so
    C:/Users/simon/repos/rugby-unity/Library/il2cpp_android_arm64-v8a/il2cpp_cache/libil2cpp/DBC5130846C16018DCB65FE676D3FFB2.o: In function `std::__ndk1::__libcpp_allocate(unsigned long, unsigned long)':
    C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/../sysroot/usr/include/c++/v1/new:259:(.text._ZN6il2cpp2os17OpenAndroidConfigEv+0x9c): relocation truncated to fit: R_AARCH64_CALL26 against symbol `operator new(unsigned long)' defined in .text._Znwm section in C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/../sysroot/usr/lib/aarch64-linux-android\libc++_static.a(new.o)
    C:/Users/simon/repos/rugby-unity/Library/il2cpp_android_arm64-v8a/il2cpp_cache/libil2cpp/DBC5130846C16018DCB65FE676D3FFB2.o: In function `std::__ndk1::char_traits<char>::length(char const*)':
    C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/../sysroot/usr/include/c++/v1/__string:217:(.text._ZN6il2cpp2os17OpenAndroidConfigEv+0xd0): relocation truncated to fit: R_AARCH64_CALL26 against symbol `strlen@@LIBC' defined in .text section in C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/../sysroot/usr/lib/aarch64-linux-android/21/libc.so
    C:/Users/simon/repos/rugby-unity/Library/il2cpp_android_arm64-v8a/il2cpp_cache/libil2cpp/DBC5130846C16018DCB65FE676D3FFB2.o: In function `std::__ndk1::_DeallocateCaller::__do_call(void*)':
    C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/../sysroot/usr/include/c++/v1/new:340:(.text._ZN6il2cpp2os17OpenAndroidConfigEv+0x114): relocation truncated to fit: R_AARCH64_CALL26 against symbol `operator delete(void*)' defined in .text._ZdlPv section in C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/../sysroot/usr/lib/aarch64-linux-android\libc++_static.a(new.o)
    C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/../sysroot/usr/include/c++/v1/new:340:(.text._ZN6il2cpp2os17OpenAndroidConfigEv+0x124): relocation truncated to fit: R_AARCH64_CALL26 against symbol `operator delete(void*)' defined in .text._ZdlPv section in C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/../sysroot/usr/lib/aarch64-linux-android\libc++_static.a(new.o)
    C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/../sysroot/usr/include/c++/v1/new:340:(.text._ZN6il2cpp2os17OpenAndroidConfigEv+0x18c): relocation truncated to fit: R_AARCH64_CALL26 against symbol `operator delete(void*)' defined in .text._ZdlPv section in C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/../sysroot/usr/lib/aarch64-linux-android\libc++_static.a(new.o)
    C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/../sysroot/usr/include/c++/v1/new:340:(.text._ZN6il2cpp2os17OpenAndroidConfigEv+0x1c4): relocation truncated to fit: R_AARCH64_CALL26 against symbol `operator delete(void*)' defined in .text._ZdlPv section in C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackE<message truncated>​
     
    Last edited: Dec 23, 2020
    Aldeminor likes this.
  2. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    Unfortunately, this is a known bug in the Android NDK r19 used with this version of Unity. When the executable size is too large, the native linker in the Android NDK will fail with this error. Enabling script debugging with IL2CPP adds a good bit of code size, and triggers this issue.

    This is corrected in newer NDK versions, but at the moment, we can't correct it in Unity versions before 2021.1. We're investigating ways to work around this issue.
     
  3. notSimon

    notSimon

    Joined:
    Feb 19, 2018
    Posts:
    4
    Ahh, that's a bummer. Thanks for the response though.
     
  4. notSimon

    notSimon

    Joined:
    Feb 19, 2018
    Posts:
    4
    "When the executable size is too large"
    What might count as too large?

    Do you have any guidance on how we might overcome this issue, besides updating to 2021.1?
     
  5. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    I'm not sure what executable code size will trigger this bug in the Android linker, unfortunately, as I can't specifically quantify it.

    We're working on some improvements to lower the generated code size, which I hope to back port - but they are not ready yet.

    From your end, you can can review the code in your project. Determine if it is all necessary. You can increase the managed code stripping level to allow our managed code stripping tool to remove unused code. You can find details about this in our documentation here: https://docs.unity3d.com/Manual/ManagedCodeStripping.html
     
  6. shochet

    shochet

    Joined:
    Dec 17, 2013
    Posts:
    30
    Had this same problem - our Android build has been failing last 6 days with confusing linker errors. Glad I found this thread!
    Turning on "Strip Engine Code" (our project had it off) and changing "Managed Stripping Level" from Low to High seems to have helped the build finish. Hopefully there will not be any missing code at runtime - will test soon.
    (Unity 2019.4.18)
    Oddly we were only seeing the problem in command line builds - editor builds worked fine.
     
  7. RDeluxe

    RDeluxe

    Joined:
    Sep 29, 2013
    Posts:
    117
    Encountered the same issue, and lost WAY too much time debugging this ...

    This only happens if we try to build against ARM64, ARMv7 builds are working just fine.

    Disabling code debugging solves the issue, but that's not a solution. Will try to bump code stripping from low to medium,
     
  8. MassiveTchnologies

    MassiveTchnologies

    Joined:
    Jul 5, 2016
    Posts:
    87
    The issue is not fixed even in unity 2021.1.15f1. What gives?
     
  9. MassiveTchnologies

    MassiveTchnologies

    Joined:
    Jul 5, 2016
    Posts:
    87
    Is the fix included in unity 2021.1.15f1? The build stil lfails when Script Debugging is enabled...
     
  10. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    We could not come up with a good work around in Unity 2021.1, due to some other problems with the Android NDK tools. We attempted to use the lld linker in that version of Unity, but that lead to performance regressions, from what I understand, although I was not directly involved in this work.

    In Unity 2021.2, we have a new IL2CPP code generation option that significantly reduces code size - check it out in the Build Settings dialog. I think that will be the best option to work around this issue for projects that cannot make the code size lower manually.
     
    MAATpe likes this.
  11. MassiveTchnologies

    MassiveTchnologies

    Joined:
    Jul 5, 2016
    Posts:
    87
    Thanks! For the meantime, changing the stripping level to medium fixed the issue. But broke a lot of parts of our serialization system that is too much headache to deal with
     
  12. Remstam

    Remstam

    Joined:
    Oct 6, 2017
    Posts:
    23
    @JoshPeterson From what I understand, linking large source base for ARM64 with ld.bfd can cause creation of a pretty large stub groups, so resizing it with --stub-group-size linker flag might be a workaround

    What you need is to try PlayerSettings.SetAdditionalIl2CppArgs("--linker-flags=\"-Wl,--stub-group-size=11534360\") (that is 110 MB per group) prior build.

    The only issue there is that linker flag is obviously ARM64-only, thus ARM7 will fail if both architectures were chosen to build - because linker flags from additional cpp args are applied to all architectures at once.

    Is there any way to separate linker flags setup for different architectures?
     
  13. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    I was not aware of that flag - that is an interesting option. I don't believe there is a way to add it for just one architecture now, but we may be able to always pass it internally for ARM64 builds.
     
    kjyv, RDeluxe and Remstam like this.
  14. ilyas_d

    ilyas_d

    Joined:
    Nov 7, 2019
    Posts:
    4
    Are there any news to this issue, I am using Unity 2021.2.13f1 and it is still not possible to enable script debugging without causing the android build to fail.
     
  15. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    There are changes coming for Unity 2022.2 that update to a newer Android NDK (r23) and use lld as the native linker. Those changes alleviate this issue for most projects.
     
    Remstam and jeremedia like this.
  16. ilyas_d

    ilyas_d

    Joined:
    Nov 7, 2019
    Posts:
    4
    Is it possible to push those changes to Unity 2021 too because 2022 is still beta if I am not wrong. And using a beta version of Unity for a production ready project would be far from optimal.
     
  17. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    Unfortunately no - this Android NDK update required a number of changes, from what I understand.
     
  18. ilyas_d

    ilyas_d

    Joined:
    Nov 7, 2019
    Posts:
    4
    Yes this is unfortunate and impractical. Thank you for your quick replies!
     
  19. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    Sorry that I don't have better news!
     
  20. HappyPlaying

    HappyPlaying

    Joined:
    Nov 3, 2019
    Posts:
    6
    I had the problem in 2020.3.28. Setting the code stripping from low to medium solved it.
     
    ohavitd likes this.
  21. okluckej_unity

    okluckej_unity

    Joined:
    Aug 30, 2020
    Posts:
    11
    Thanks works like a charm. This is 3rd linker issue we got on different platforms and finally there was a magic solution already posted in the thread :)
     
  22. BBlake3

    BBlake3

    Joined:
    Aug 3, 2020
    Posts:
    2
    Last edited: Dec 2, 2022
  23. Remstam

    Remstam

    Joined:
    Oct 6, 2017
    Posts:
    23
  24. Remstam

    Remstam

    Joined:
    Oct 6, 2017
    Posts:
    23


    Unity 2022.2 is finally out:
    https://unity.com/releases/editor/whats-new/2022.2.0

    There is a problem related statement in release notes:
    • Android: Upgraded to using Android NDK r23b. Default linker is now lld which fixes issues with large projects and IL2CPP
    So it should be fine once 2022LTS is out too.
     
  25. LilGames

    LilGames

    Joined:
    Mar 30, 2015
    Posts:
    570
    So this still happens in 2021.3. What is the solution, just upgrading to 2022?
     
  26. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    Yes, this will be your best bet to fix it, I think.
     
    LilGames likes this.