google / play-instant-unity-plugin

Google Play Instant Plugin for Unity Beta (Archived)
https://developer.android.com/topic/google-play-instant/getting-started/game-unity-plugin
Apache License 2.0
148 stars 31 forks source link

Build error with Unity 2018.4 and IL2CPP #143

Closed ValeriaColombo closed 4 years ago

ValeriaColombo commented 4 years ago

In Unity 2018.4.4f1, when building with IL2CPP enabled, throws this error (Mono works fine)

`Failed running /Applications/Unity/Hub/Editor/2018.4.4f1/Unity.app/Contents/il2cpp/build/il2cppcore/il2cppcore.dll --convert-to-cpp --emit-null-checks --enable-array-bounds-check --dotnetprofile="unityaot" --compile-cpp --libil2cpp-static --platform="Android" --architecture="ARMv7" --configuration="Release" --outputpath="/Users/valeria/Desktop/projects/fenix-instant-app-3/Temp/StagingArea/assets/bin/Data/Native/armeabi-v7a/libil2cpp.so" --cachedirectory="/Users/valeria/Desktop/projects/fenix-instant-app-3/Assets/../Library/il2cpp_android_armeabi-v7a/il2cpp_cache" --additional-include-directories="/Applications/Unity/Hub/Editor/2018.4.4f1/PlaybackEngines/AndroidPlayer/Tools/bdwgc/include" --additional-include-directories="/Applications/Unity/Hub/Editor/2018.4.4f1/PlaybackEngines/AndroidPlayer/Tools/libil2cpp/include" --tool-chain-path="/Users/valeria/Library/Android/android-ndk-r16b" --map-file-parser="/Applications/Unity/Hub/Editor/2018.4.4f1/Unity.app/Contents/Tools/MapFileParser/MapFileParser" --directory="/Users/valeria/Desktop/projects/fenix-instant-app-3/Temp/StagingArea/assets/bin/Data/Managed" --generatedcppdir="/Users/valeria/Desktop/projects/fenix-instant-app-3/Temp/StagingArea/Il2Cpp/il2cppOutput"

stdout: Building libil2cpp.so with AndroidToolChain Output directory: /Users/valeria/Desktop/projects/fenix-instant-app-3/Temp/StagingArea/assets/bin/Data/Native/armeabi-v7a Cache directory: /Users/valeria/Desktop/projects/fenix-instant-app-3/Library/il2cpp_android_armeabi-v7a/il2cpp_cache il2cpp.exe didn't catch exception: Unity.IL2CPP.Building.BuilderFailedException:

Invocation was: Executable: /Users/valeria/Library/Android/android-ndk-r16b/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ Arguments: -DNET_4_0 -DUNITY_AOT -DGC_NOT_DLL -DRUNTIME_IL2CPP -DLINUX -DANDROID -DPLATFORM_ANDROID -Dlinux -DSTDC_FORMAT_MACROS -I"/Applications/Unity/Hub/Editor/2018.4.4f1/PlaybackEngines/AndroidPlayer/Tools/bdwgc/include" -I"/Applications/Unity/Hub/Editor/2018.4.4f1/PlaybackEngines/AndroidPlayer/Tools/libil2cpp/include" -I"/Applications/Unity/Hub/Editor/2018.4.4f1/Unity.app/Contents/il2cpp/libil2cpp" -I"/Applications/Unity/Hub/Editor/2018.4.4f1/Unity.app/Contents/il2cpp/external/boehmgc/include" -I"/Users/valeria/Desktop/projects/fenix-instant-app-3/Temp/StagingArea/Il2Cpp/il2cppOutput" -I"." -I"/Users/valeria/Library/Android/android-ndk-r16b/sources/cxx-stl/gnu-libstdc++/4.9/include" -I"/Users/valeria/Library/Android/android-ndk-r16b/sources/cxx-stl/gnu-libstdc++/4.9/include/backward" -I"/Users/valeria/Library/Android/android-ndk-r16b/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include" -c -g -DNDEBUG -funwind-tables -fno-limit-debug-info -fdata-sections -ffunction-sections -Wa,--noexecstack -fno-rtti -std=c++98 -fno-strict-aliasing -fvisibility=hidden -fvisibility-inlines-hidden -fno-strict-overflow -fPIC -Os --sysroot "/Users/valeria/Library/Android/android-ndk-r16b/sysroot" -gcc-toolchain "/Users/valeria/Library/Android/android-ndk-r16b/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64" -target armv7-none-linux-androideabi -isystem "/Users/valeria/Library/Android/android-ndk-r16b/sysroot/usr/include/arm-linux-androideabi" -D__ANDROID_API=16 -march=armv7-a -mfloat-abi=softfp -mfpu=neon-fp16 -Wno-unused-value "/Users/valeria/Desktop/projects/fenix-instant-app-3/Temp/StagingArea/Il2Cpp/il2cppOutput/Il2CppTypeDefinitions.cpp" -o "/Users/valeria/Desktop/projects/fenix-instant-app-3/Library/il2cpp_android_armeabi-v7a/il2cpp_cache/21516E1ED2CEE254E4E4ACA5569B6107.o"

at Unity.IL2CPP.Building.CppProgramBuilder.BuildAllCppFiles(IEnumerable`1 sourceFilesToCompile, IBuildStatisticsCollector statisticsCollector) at Unity.IL2CPP.Building.CppProgramBuilder.Build(IBuildStatistics& statistics) at il2cpp.Program.DoRun(String[] args) at il2cpp.Program.Run(String[] args) at il2cpp.Program.Main(String[] args) stderr:

Unhandled Exception: Unity.IL2CPP.Building.BuilderFailedException:

Invocation was: Executable: /Users/valeria/Library/Android/android-ndk-r16b/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ Arguments: -DNET_4_0 -DUNITY_AOT -DGC_NOT_DLL -DRUNTIME_IL2CPP -DLINUX -DANDROID -DPLATFORM_ANDROID -Dlinux -DSTDC_FORMAT_MACROS -I"/Applications/Unity/Hub/Editor/2018.4.4f1/PlaybackEngines/AndroidPlayer/Tools/bdwgc/include" -I"/Applications/Unity/Hub/Editor/2018.4.4f1/PlaybackEngines/AndroidPlayer/Tools/libil2cpp/include" -I"/Applications/Unity/Hub/Editor/2018.4.4f1/Unity.app/Contents/il2cpp/libil2cpp" -I"/Applications/Unity/Hub/Editor/2018.4.4f1/Unity.app/Contents/il2cpp/external/boehmgc/include" -I"/Users/valeria/Desktop/projects/fenix-instant-app-3/Temp/StagingArea/Il2Cpp/il2cppOutput" -I"." -I"/Users/valeria/Library/Android/android-ndk-r16b/sources/cxx-stl/gnu-libstdc++/4.9/include" -I"/Users/valeria/Library/Android/android-ndk-r16b/sources/cxx-stl/gnu-libstdc++/4.9/include/backward" -I"/Users/valeria/Library/Android/android-ndk-r16b/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include" -c -g -DNDEBUG -funwind-tables -fno-limit-debug-info -fdata-sections -ffunction-sections -Wa,--noexecstack -fno-rtti -std=c++98 -fno-strict-aliasing -fvisibility=hidden -fvisibility-inlines-hidden -fno-strict-overflow -fPIC -Os --sysroot "/Users/valeria/Library/Android/android-ndk-r16b/sysroot" -gcc-toolchain "/Users/valeria/Library/Android/android-ndk-r16b/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64" -target armv7-none-linux-androideabi -isystem "/Users/valeria/Library/Android/android-ndk-r16b/sysroot/usr/include/arm-linux-androideabi" -D__ANDROID_API=16 -march=armv7-a -mfloat-abi=softfp -mfpu=neon-fp16 -Wno-unused-value "/Users/valeria/Desktop/projects/fenix-instant-app-3/Temp/StagingArea/Il2Cpp/il2cppOutput/Il2CppTypeDefinitions.cpp" -o "/Users/valeria/Desktop/projects/fenix-instant-app-3/Library/il2cpp_android_armeabi-v7a/il2cpp_cache/21516E1ED2CEE254E4E4ACA5569B6107.o"

at Unity.IL2CPP.Building.CppProgramBuilder.BuildAllCppFiles(IEnumerable`1 sourceFilesToCompile, IBuildStatisticsCollector statisticsCollector) at Unity.IL2CPP.Building.CppProgramBuilder.Build(IBuildStatistics& statistics) at il2cpp.Program.DoRun(String[] args) at il2cpp.Program.Run(String[] args) at il2cpp.Program.Main(String[] args) at Program.Main(String[] args)

UnityEngine.Debug:LogError(Object) UnityEditorInternal.Runner:RunProgram(Program, String, String, String, CompilerOutputParserBase) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildUtils.cs:128) UnityEditorInternal.Runner:RunNetCoreProgram(String, String, String, CompilerOutputParserBase, Action1) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildUtils.cs:79) UnityEditorInternal.IL2CPPBuilder:RunIl2CppWithArguments(List1, Action1, String) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:366) UnityEditorInternal.IL2CPPBuilder:ConvertPlayerDlltoCpp(String, String, String, Boolean) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:349) UnityEditorInternal.IL2CPPBuilder:Run() (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:211) UnityEditorInternal.IL2CPPUtils:RunIl2Cpp(String, String, IIl2CppPlatformProvider, Action1, RuntimeClassRegistry) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:35) UnityEditor.BuildPipeline:BuildPlayer(BuildPlayerOptions) GooglePlayInstant.Editor.PlayInstantBuilder:Build(BuildPlayerOptions) (at Assets/GooglePlayInstant/Editor/PlayInstantBuilder.cs:224) GooglePlayInstant.Editor.PlayInstantBuilder:BuildAndSign(BuildPlayerOptions) (at Assets/GooglePlayInstant/Editor/PlayInstantBuilder.cs:173) GooglePlayInstant.Editor.PlayInstantPublisher:Build() (at Assets/GooglePlayInstant/Editor/PlayInstantPublisher.cs:53) GooglePlayInstant.Editor.PlayInstantEditorMenu:BuildForPlayConsole() (at Assets/GooglePlayInstant/Editor/PlayInstantEditorMenu.cs:101) `

Here is a Screnshot of Player Settings of my project

thanwah commented 4 years ago

Hello, thank you for reporting this issue.

A colleague and I have both tried to reproduce this issue on a Mac running Unity 2018.4 without success. We're both able to build an instant app APK with IL2CPP on 2018.4.

One challenge with this issue is that "il2cpp.exe didn't catch exception: Unity.IL2CPP.Building.BuilderFailedException" gives the clang++ command line invocation that failed, but to my reading doesn't indicate what the underlying cause was.

If you switch your project's "PlayInstant > Build Settings... > Android Build Type" from "Instant" back to "Installed" and build again, does the exception still occur for IL2CPP builds?

ValeriaColombo commented 4 years ago

Yes, I aready tried that.

Here: https://drive.google.com/file/d/10C7wjINdXTcD54tGAkdcVSned3FDhLek/view?usp=sharing

You can find a demo project I made that fails with that error when I use the "PlayInstant --> Build for Play Console" option

thanwah commented 4 years ago

Thank you for sharing the demo project.

I tried it out on Unity 2018.4.13f1 with NDK r16b on computer MacOS 10.14. I tried building with IL2CPP several times with toggling various settings (.NET version, engine stripping, etc) and wasn't able to reproduce the issue.

I'm not sure what to suggest at this point other than installing the latest Unity 2018.4 or perhaps reinstalling some of the other dependencies such as the Android NDK?

ValeriaColombo commented 4 years ago

Ok, thanks to your info on what MacOS version you were using, I remembered I had updated to Catalina recently, investigated a little, and found out the error I was having was this one: https://forum.unity.com/threads/clang-cannot-be-opened.759941/

Now I can build without problems!!!

Thank you for your help!