Hi,
I tried to compile (an empty project with ml-agents+tensorFlow) to android using il2cpp.
i get this error:
Failed running /Applications/Unity/Hub/Editor/2018.1.0b10/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/***/Workspace/Unity/TestML/Temp/StagingArea/assets/bin/Data/Native/armeabi-v7a/libil2cpp.so" --cachedirectory="/Users/***/Workspace/Unity/TestML/Assets/../Library/il2cpp_android_armeabi-v7a/il2cpp_cache" --additional-include-directories="/Applications/Unity/Hub/Editor/2018.1.0b10/PlaybackEngines/AndroidPlayer/Tools/bdwgc/include" --additional-include-directories="/Applications/Unity/Hub/Editor/2018.1.0b10/PlaybackEngines/AndroidPlayer/Tools/libil2cpp/include" --tool-chain-path="/Users/***/Downloads/android-ndk-r13b" --map-file-parser="/Applications/Unity/Hub/Editor/2018.1.0b10/Unity.app/Contents/Tools/MapFileParser/MapFileParser" --assembly="/Users/***/Workspace/Unity/TestML/Temp/StagingArea/assets/bin/Data/Managed/Assembly-CSharp.dll" --assembly="/Users/***/Workspace/Unity/TestML/Temp/StagingArea/assets/bin/Data/Managed/ML-Agents.Runtime.dll" --assembly="/Users/***/Workspace/Unity/TestML/Temp/StagingArea/assets/bin/Data/Managed/UnityEngine.dll" --generatedcppdir="/Users/***/Workspace/Unity/TestML/Temp/StagingArea/Il2Cpp/il2cppOutput"
stdout:
Building libil2cpp.so with AndroidToolChain.
Output directory: /Users/***/Workspace/Unity/TestML/Temp/StagingArea/assets/bin/Data/Native/armeabi-v7a
Cache directory: /Users/***/Workspace/Unity/TestML/Library/il2cpp_android_armeabi-v7a/il2cpp_cache
ObjectFiles: 584 of which compiled: 584
Time Compile: 6649 milliseconds Bulk_System.Xml_0.cpp
Time Compile: 6511 milliseconds Bulk_System.Data_2.cpp
Time Compile: 6247 milliseconds Bulk_System.Data_0.cpp
Time Compile: 6235 milliseconds Il2CppInvokerTable.cpp
Time Compile: 6066 milliseconds Bulk_System.Xml_2.cpp
Time Compile: 5717 milliseconds Il2CppAttributes.cpp
Time Compile: 5590 milliseconds Bulk_System.Xml_5.cpp
Time Compile: 5490 milliseconds Bulk_Newtonsoft.Json_1.cpp
Time Compile: 5444 milliseconds Bulk_mscorlib_9.cpp
Time Compile: 5365 milliseconds Bulk_System.Xml_6.cpp
Total compilation time: 111254 milliseconds.
il2cpp.exe didn't catch exception: Unity.IL2CPP.Building.BuilderFailedException: /Users/***/Downloads/android-ndk-r13b/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ @"/var/folders/vv/dc3h11_s6jnd3qf6vmx25nf40000gn/T/tmpsNYqM6.tmp" -o "/Users/***/Workspace/Unity/TestML/Library/il2cpp_android_armeabi-v7a/il2cpp_cache/linkresult_85EFD5BB4AE0BFA73CEBA67351F6CBF6/libil2cpp.so" -shared -Wl,-soname,libil2cpp.so -Wl,--no-undefined -Wl,-z,noexecstack -Wl,--gc-sections -Wl,--build-id --sysroot "/Users/***/Downloads/android-ndk-r13b/platforms/android-16/arch-arm" -gcc-toolchain "/Users/***/Downloads/android-ndk-r13b/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64" -target armv7-none-linux-androideabi -Wl,--wrap,sigaction -L "/Users/***/Downloads/android-ndk-r13b/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a" -lgnustl_static -llog -Xlinker -Map="/Users/***/Workspace/Unity/TestML/Library/il2cpp_android_armeabi-v7a/il2cpp_cache/linkresult_85EFD5BB4AE0BFA73CEBA67351F6CBF6/libil2cpp.map" -rdynamic -fPIE -pie -fuse-ld=bfd
clang++: warning: argument unused during compilation: '-pie'
/Users/***/Workspace/Unity/TestML/Library/il2cpp_android_armeabi-v7a/il2cpp_cache/5228929F7942C57C604BDBA68C6FE957.o: In function `JNIEnv_monodroid_typemap_managed_to_java_m2218082999':
/Users/***/Workspace/Unity/TestML/Temp/StagingArea/Il2Cpp/il2cppOutput/Bulk_Mono.Android_0.cpp:20726: undefined reference to `monodroid_typemap_managed_to_java'
/Users/***/Workspace/Unity/TestML/Library/il2cpp_android_armeabi-v7a/il2cpp_cache/5228929F7942C57C604BDBA68C6FE957.o: In function `JNIEnv__monodroid_gref_log_m2157010344':
/Users/***/Workspace/Unity/TestML/Temp/StagingArea/Il2Cpp/il2cppOutput/Bulk_Mono.Android_0.cpp:20552: undefined reference to `_monodroid_gref_log'
/Users/***/Workspace/Unity/TestML/Library/il2cpp_android_armeabi-v7a/il2cpp_cache/5228929F7942C57C604BDBA68C6FE957.o: In function `JNIEnv_monodroid_typemap_managed_to_java_m2218082999':
/Users/***/Workspace/Unity/TestML/Temp/StagingArea/Il2Cpp/il2cppOutput/Bulk_Mono.Android_0.cpp:20726: undefined reference to `monodroid_typemap_managed_to_java'
/Users/***/Workspace/Unity/TestML/Library/il2cpp_android_armeabi-v7a/il2cpp_cache/91839069CCF770ADA59BF3218EBC8ABD.o: In function `TypeManager_monodroid_typemap_java_to_managed_m1835138788':
/Users/***/Workspace/Unity/TestML/Temp/StagingArea/Il2Cpp/il2cppOutput/Bulk_Mono.Android_1.cpp:8199: undefined reference to `monodroid_typemap_java_to_managed'
/Users/***/Workspace/Unity/TestML/Temp/StagingArea/Il2Cpp/il2cppOutput/Bulk_Mono.Android_1.cpp:8199: undefined reference to `monodroid_typemap_java_to_managed'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
at Unity.IL2CPP.Building.CppProgramBuilder.PostprocessObjectFiles(IEnumerable`1 objectFiles, CppToolChainContext toolChainContext)
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: /Users/***/Downloads/android-ndk-r13b/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ @"/var/folders/vv/dc3h11_s6jnd3qf6vmx25nf40000gn/T/tmpsNYqM6.tmp" -o "/Users/***/Workspace/Unity/TestML/Library/il2cpp_android_armeabi-v7a/il2cpp_cache/linkresult_85EFD5BB4AE0BFA73CEBA67351F6CBF6/libil2cpp.so" -shared -Wl,-soname,libil2cpp.so -Wl,--no-undefined -Wl,-z,noexecstack -Wl,--gc-sections -Wl,--build-id --sysroot "/Users/***/Downloads/android-ndk-r13b/platforms/android-16/arch-arm" -gcc-toolchain "/Users/***/Downloads/android-ndk-r13b/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64" -target armv7-none-linux-androideabi -Wl,--wrap,sigaction -L "/Users/***/Downloads/android-ndk-r13b/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a" -lgnustl_static -llog -Xlinker -Map="/Users/***/Workspace/Unity/TestML/Library/il2cpp_android_armeabi-v7a/il2cpp_cache/linkresult_85EFD5BB4AE0BFA73CEBA67351F6CBF6/libil2cpp.map" -rdynamic -fPIE -pie -fuse-ld=bfd
clang++: warning: argument unused during compilation: '-pie'
/Users/***/Workspace/Unity/TestML/Library/il2cpp_android_armeabi-v7a/il2cpp_cache/5228929F7942C57C604BDBA68C6FE957.o: In function `JNIEnv_monodroid_typemap_managed_to_java_m2218082999':
/Users/***/Workspace/Unity/TestML/Temp/StagingArea/Il2Cpp/il2cppOutput/Bulk_Mono.Android_0.cpp:20726: undefined reference to `monodroid_typemap_managed_to_java'
/Users/***/Workspace/Unity/TestML/Library/il2cpp_android_armeabi-v7a/il2cpp_cache/5228929F7942C57C604BDBA68C6FE957.o: In function `JNIEnv__monodroid_gref_log_m2157010344':
/Users/***/Workspace/Unity/TestML/Temp/StagingArea/Il2Cpp/il2cppOutput/Bulk_Mono.Android_0.cpp:20552: undefined reference to `_monodroid_gref_log'
/Users/***/Workspace/Unity/TestML/Library/il2cpp_android_armeabi-v7a/il2cpp_cache/5228929F7942C57C604BDBA68C6FE957.o: In function `JNIEnv_monodroid_typemap_managed_to_java_m2218082999':
/Users/***/Workspace/Unity/TestML/Temp/StagingArea/Il2Cpp/il2cppOutput/Bulk_Mono.Android_0.cpp:20726: undefined reference to `monodroid_typemap_managed_to_java'
/Users/***/Workspace/Unity/TestML/Library/il2cpp_android_armeabi-v7a/il2cpp_cache/91839069CCF770ADA59BF3218EBC8ABD.o: In function `TypeManager_monodroid_typemap_java_to_managed_m1835138788':
/Users/***/Workspace/Unity/TestML/Temp/StagingArea/Il2Cpp/il2cppOutput/Bulk_Mono.Android_1.cpp:8199: undefined reference to `monodroid_typemap_java_to_managed'
/Users/***/Workspace/Unity/TestML/Temp/StagingArea/Il2Cpp/il2cppOutput/Bulk_Mono.Android_1.cpp:8199: undefined reference to `monodroid_typemap_java_to_managed'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
at Unity.IL2CPP.Building.CppProgramBuilder.PostprocessObjectFiles(IEnumerable`1 objectFiles, CppToolChainContext toolChainContext)
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, Action`1) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildUtils.cs:79)
UnityEditorInternal.IL2CPPBuilder:RunIl2CppWithArguments(List`1, Action`1, String) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:345)
UnityEditorInternal.IL2CPPBuilder:ConvertPlayerDlltoCpp(ICollection`1, String, String, Boolean) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:328)
UnityEditorInternal.IL2CPPBuilder:Run() (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:161)
UnityEditorInternal.IL2CPPUtils:RunIl2Cpp(String, String, IIl2CppPlatformProvider, Action`1, RuntimeClassRegistry) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:34)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
if I try to disable Assets/Plugins/Android/Mono.Android.dll, then I get this error:
ArgumentException: The Assembly Mono.Android is referenced by TensorFlowSharp.Android ('Assets/ML-Agents/Plugins/Android/TensorFlowSharp.Android.dll'). But the dll is not allowed to be included or could not be found.
UnityEditor.AssemblyHelper.AddReferencedAssembliesRecurse (System.String assemblyPath, System.Collections.Generic.List`1[T] alreadyFoundAssemblies, System.String[] allAssemblyPaths, System.String[] foldersToSearch, System.Collections.Generic.Dictionary`2[TKey,TValue] cache, UnityEditor.BuildTarget target) (at /Users/builduser/buildslave/unity/build/Editor/Mono/AssemblyHelper.cs:140)
UnityEditor.AssemblyHelper.AddReferencedAssembliesRecurse (System.String assemblyPath, System.Collections.Generic.List`1[T] alreadyFoundAssemblies, System.String[] allAssemblyPaths, System.String[] foldersToSearch, System.Collections.Generic.Dictionary`2[TKey,TValue] cache, UnityEditor.BuildTarget target) (at /Users/builduser/buildslave/unity/build/Editor/Mono/AssemblyHelper.cs:146)
UnityEditor.AssemblyHelper.AddReferencedAssembliesRecurse (System.String assemblyPath, System.Collections.Generic.List`1[T] alreadyFoundAssemblies, System.String[] allAssemblyPaths, System.String[] foldersToSearch, System.Collections.Generic.Dictionary`2[TKey,TValue] cache, UnityEditor.BuildTarget target) (at /Users/builduser/buildslave/unity/build/Editor/Mono/AssemblyHelper.cs:146)
UnityEditor.AssemblyHelper.FindAssembliesReferencedBy (System.String[] paths, System.String[] foldersToSearch, UnityEditor.BuildTarget target) (at /Users/builduser/buildslave/unity/build/Editor/Mono/AssemblyHelper.cs:180)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
is il2cpp on android supported? (or will eventually be?)
thanks for filing. we've logged this bug and will report back once we have a resolution.
Hi @m-ronchi, we've only tried to compile it against Mono, could you please tell us why you need il2cpp instead of Mono? We will try to work on getting il2cpp to work if that is really necessary.
@xiaomaogy we are developing for both Android and iOS, and using the same backend helps avoiding some gotchas (i.e. AOT compilation) before switching to iOS. also:
1) Unity is pushing IL2CPP for all platforms
2) IL2CPP should be faster than mono
3) eventually, 64-bit
@m-ronchi I've tried to compiled against IL2CPP for android, and got the same error as you do. The TensorFlowSharp plugin for Android we use is from this repo, which only supports Mono. For the short term, I think we don't have a plan to support IL2CPP for Android given the current situation, but you are welcome to contribute on this if you are interested, and we will incorporate that.
@xiaomaogy Oh my god it's really necessary to have TensoeFlowSharp working for IL2CPP Android.
The mono on Android uses JIT compilation, which causes game to stutter when functions are first called or sometimes for no reason, but on IL2CPP with AOT compilation, it's silky smooth, that's the main reason why we immediately switched to Android IL2CPP when it came out.
Please add support for IL2CPP, I don't want to add ML then the game stutters because of JIT.
IL2CPP is broken with ML-Agents in general, not just with Android. I made a forum post for it breaking on Windows standalone here. I just started looking at ML-Agents but once I found IL2CPP doesn't work, it's a no-go as I really need IL2CPP to work (using Mono is no option).
edit: workarounds on following posts
Hey all, I came across this issue as well, we're really just using the implementation of TensorFlowSharp in our project. There were 2 issues, TensorFlowSharp.Android (or perhaps its dependencies) was causing IL2CPP builds to fail, and the TensorFlowSharp DLL had a runtime problem in it as well.
Turns out we didn't need anything to do with the Native Android Binding (it mostly looks to just provide logging..), so we could remove TensorFlowSharp.Android.dll, and get rid of it's dependencies, as well as the rest of the DLL's since we were using .NET Standard 2.0 in our project. I also had to make a couple small tweaks to TensorFlowSharp.
So for those of you having this issue using TensorFlowSharp with IL2CPP:
ML-Agents/Plugins/Android1.7.0-il2cpp (you can see my changes here)ML-Agents/Plugins/Android, make sure it's only accessible from Android buildsTensorFlowSharp has since fixed this, but the native binaries in ML-Agents use TF 1.7, and TF# 1.7 has this bug.
Thanks for your contribution @lkuich! We will also take a look at your fix and maybe use this in our next release once this becomes our priority.
Hey @xiaomaogy, that's awesome, glad I could be of help! You guys are doing great work.
Thanks @lkuich! This also fixed the IL2CPP compilation on Windows for the TensorFlowSharp.
This alone isn't enough to compile using IL2CPP on Windows, you also need to modify Grpc.Core to get rid of the dlopen and dlsym calls that are meant for Linux and MacOS anyway. IL2CPP gets confused as it tries to find these methods but can't.
After you fix these both, you can build normally with IL2CPP on Windows, even using .NET 4.x as Api compatibility level.
Here's also my Grpc change: https://github.com/0lento/grpc/commit/0b61d95b77eb1f31bda18f2c798adc286cf9a511
It only strips out unneeded platforms from one file upon compilation but obviously for this to work, you have to host the Grpc.Core sources (https://github.com/0lento/grpc/tree/v1.10.0-Unity/src/csharp/Grpc.Core) on your project somewhere and remove the precompiled Grpc.Core.dll. I actually did similar deal with TensorFlowSharp for now, I just added asmdef to the folder so it generates a new dll for mono, no need to precompile it either unless you want to.
Thanks @0lento, that's awesome!
Just wanted to add an update here, we were struggling to get our app approved by Google Play because our APK included libpng 1.2.53, which has a known security issue in it. This was pretty strange as I was seeing this issue even when using a TensorFlow 1.12 binary I compiled myself making sure it had a newer version of libpng. Apparently TF's old cmake build for TF 1.8 or less used libpng 1.2.53, this had been corrected in their newer bazel build system. So it may be worth grabbing a newer binary from JFrog for your Windows build, as the one bundled with ML-Agents now has a hole in it with libpng 1.2.53.
Turns out ML-Agents is configured out of the box to include ML-Agents/Plugins/Computer/libtensorflow_framework.so in all builds! Simply disabling it for Android and iOS builds resolved the issue for me and we were finally able to get this out the door!
cc: @xiaomaogy, I think a lot of people are going to see this issue when trying to deploy on mobile.
Can someone post the modified DLL here please?
Edit: I've successfully built the DLL. But when I remove all the DLLs from ML-Agents/Plugins/Android and copy the modified DLL, my project breaks completely. I got a bunch of crazy errors without even trying to build. The only way I found to go back to normal was reimporting TensorFlowSharp
I'm not familiar with Visual Studio and I'm not even sure about what I'm doing exactly. I'd appreciate some help with that!
@13Flo The above linked package is not TensorflowSharp, but the full ML-Agents plugin for Unity. You may have numerous references to the deleted packages in ML-Agents/Plugins/Android (using ML-Agents and not explicitly TensorflowSharp). I can't really suggest what to do without knowing more about your project and said error messages. You need to determine if you need ML-Agents, or just TensorflowSharp. If you just need TensorflowSharp, you can remove ML-Agents completely and use the modified TensorflowSharp fork above (I presume you're referring to the DLL for that above).
I'd suggest instead becoming more familiar with C# and Visual Studio before diving deep into Tensorflow/TF-Sharp!
@lkuich Thanks for your reply!
I don't think the link I posted is "the full ML-Agents plugin for Unity". Here are the files it contains:

I found it in the Requirements here. That said, I'm not sure to understand why we need to use that specific .unitypackage for ML-Agents (0.6a) to work.
I'm very familiar with ML-Agents now in general (not TensorFlow) and I successfully use it in my racing game to train AI opponents. My project is more in an "optimisation" phase now and I know for a fact that using IL2CPP drastically improves performances (and also increases build time).
The thing is I am not entirely sure about the way I "Rebuilt TensorFlowSharp" (with VS) as you suggested in your message above.
Can anybody help me with this? I am not a TensorFlow expert. I am just trying to use ML-Agents as any other game developer would, using IL2CPP to improve my game performances. And as far as I understand, this Issues tracker page is about ML-Agents :) If there is a workaround, I'd love to apply it!
@13Flo The bundle you've linked above is just TensorFlowSharp, there's nothing specific for ML-Agents in there (this also confused me for a while and I wondered why it's provided in the first place under ML-Agents). What are you using Tensorflow for exactly? It sounds like you're just using ML-Agents, not Tensorflow. My case was the other way around, I was only using Tensorflow and not ML-Agents.
Regardless, this is my modified Tensorflow implementation that I have working with Unity:
https://storage.googleapis.com/ir-public/ML-Agents-lkuich-patch.unitypackage
Please note this uses Tensorflow 1.7. I'd eventually like to upgrade the respective binaries to the current supported TF version at some point in the future.
You'll notice the structure is quite a bit slimmer:

@lkuich Thank you again for your reply.
As far as I undersand, I believe TensorFlowSharp plugin is used only at runtime, when using a trained model. Thanks for the .unitypakage, I'll try this ASAP and let you know how it goes.
In my game specifically, I use ML-Agents to train opponents AI mostly using raycasting (called Perception in the examples). It works great and I am so excited about it. My agents can stay on the road, avoid obstacles and catch powerups on the way. I'm literally blown away by the possibilities this offers. The game is mobile VR and IL2CPP would be very welcome to reduce CPU load.
"The Unity Inference Engine replaces TensorFlowSharp for Inference"
https://github.com/Unity-Technologies/ml-agents/releases/tag/0.7.0
@lkuich I tried to build with IL2CPP using your _ML-Agents-lkuich-patch.unitypackage_ but I still git that error :/
```Failed running E:\Unity\Hub\Editor\2018.3.6f1\Editor\Data\il2cpp/build/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="E:\Unity Projects\Racing Game\Temp\StagingArea\assets\bin\Data\Native\armeabi-v7alibil2cpp.so" --cachedirectory="E:\Unity Projects\Racing Game\Assets..\Library\il2cpp_android_armeabi-v7a/il2cpp_cache" --additional-include-directories="E:\Unity\Hub\Editor\2018.3.6f1\Editor\Data\PlaybackEngines\AndroidPlayer/Tools\bdwgc/include" --additional-include-directories="E:\Unity\Hub\Editor\2018.3.6f1\Editor\Data\PlaybackEngines\AndroidPlayer/Toolslibil2cpp/include" --tool-chain-path="D:/android-ndk-r16b" --map-file-parser="E:\Unity\Hub\Editor\2018.3.6f1\Editor\Data\Tools\MapFileParser\MapFileParser.exe" --directory="E:\Unity Projects\Racing Game\Temp\StagingArea\assets\bin\Data\Managed" --generatedcppdir="E:\Unity Projects\Racing Game\Temp\StagingArea\Il2Cpp\il2cppOutput"
stdout:
Building libil2cpp.so with AndroidToolChain
Output directory: E:\Unity Projects\Racing Game\Temp\StagingArea\assets\bin\Data\Native\armeabi-v7a
Cache directory: E:\Unity Projects\Racing Game\Library\il2cpp_android_armeabi-v7a\il2cpp_cache
ObjectFiles: 721 of which compiled: 721
Time Compile: 24380 milliseconds Il2CppInvokerTable.cpp
Time Compile: 22049 milliseconds Il2CppAttributes.cpp
Time Compile: 15019 milliseconds Bulk_Unity.ProBuilder_0.cpp
Time Compile: 12298 milliseconds Il2CppTypeDefinitions.cpp
Time Compile: 9314 milliseconds Bulk_System.Xml_9.cpp
Time Compile: 9093 milliseconds Bulk_Assembly-CSharp_5.cpp
Time Compile: 9026 milliseconds Bulk_Unity.TextMeshPro_2.cpp
Time Compile: 8717 milliseconds Bulk_Oculus.VR_3.cpp
Time Compile: 8329 milliseconds Bulk_Assembly-CSharp_2.cpp
Time Compile: 8280 milliseconds Bulk_Unity.TextMeshPro_1.cpp
Total compilation time: 156428 milliseconds.
il2cpp.exe didn't catch exception: Unity.IL2CPP.Building.BuilderFailedException: D:\android-ndk-r16b\toolchains\llvm\prebuilt\windows-x86_64\binclang++ @"C:\Users\Florian\AppData\Local\Temp\tmp7EBA.tmp" -o "E:\Unity Projects\Racing Game\Library\il2cpp_android_armeabi-v7a\il2cpp_cache\linkresult_0903E3DB497502A78E5A044C590D14F0libil2cpp.so" -shared -Wl,-soname,libil2cpp.so -Wl,--no-undefined -Wl,-z,noexecstack -Wl,--gc-sections -Wl,--build-id --sysroot "D:\android-ndk-r16b\platforms\android-16\arch-arm" -gcc-toolchain "D:\android-ndk-r16b\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64" -target armv7-none-linux-androideabi -Wl,--wrap,sigaction -L "D:\android-ndk-r16b\sourcescxx-stl\gnu-libstdc++\4.9libs\armeabi-v7a" -lgnustl_static -llog -rdynamic -fuse-ld=gold.exe
E:\Unity Projects\Racing Game\Temp\StagingArea\Il2Cpp\il2cppOutput/Bulk_Mono.Android_0.cpp:14074: error: undefined reference to 'monodroid_typemap_managed_to_java'
E:\Unity Projects\Racing Game\Temp\StagingArea\Il2Cpp\il2cppOutput/Bulk_Mono.Android_0.cpp:13900: error: undefined reference to '_monodroid_gref_log'
E:\Unity Projects\Racing Game\Temp\StagingArea\Il2Cpp\il2cppOutput/Bulk_Mono.Android_0.cpp:14074: error: undefined reference to 'monodroid_typemap_managed_to_java'
E:\Unity Projects\Racing Game\Temp\StagingArea\Il2Cpp\il2cppOutput/Bulk_Mono.Android_1.cpp:13241: error: undefined reference to 'monodroid_typemap_java_to_managed'
E:\Unity Projects\Racing Game\Temp\StagingArea\Il2Cpp\il2cppOutput/Bulk_Mono.Android_1.cpp:13241: error: undefined reference to 'monodroid_typemap_java_to_managed'
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)
at il2cpp.Program.Run(String[] args)
at il2cpp.Program.Main(String[] args)
stderr:
Unhandled Exception: Unity.IL2CPP.Building.BuilderFailedException: D:\android-ndk-r16b\toolchains\llvm\prebuilt\windows-x86_64\binclang++ @"C:\Users\Florian\AppData\Local\Temp\tmp7EBA.tmp" -o "E:\Unity Projects\Racing Game\Library\il2cpp_android_armeabi-v7a\il2cpp_cache\linkresult_0903E3DB497502A78E5A044C590D14F0libil2cpp.so" -shared -Wl,-soname,libil2cpp.so -Wl,--no-undefined -Wl,-z,noexecstack -Wl,--gc-sections -Wl,--build-id --sysroot "D:\android-ndk-r16b\platforms\android-16\arch-arm" -gcc-toolchain "D:\android-ndk-r16b\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64" -target armv7-none-linux-androideabi -Wl,--wrap,sigaction -L "D:\android-ndk-r16b\sourcescxx-stl\gnu-libstdc++\4.9libs\armeabi-v7a" -lgnustl_static -llog -rdynamic -fuse-ld=gold.exe
E:\Unity Projects\Racing Game\Temp\StagingArea\Il2Cpp\il2cppOutput/Bulk_Mono.Android_0.cpp:14074: error: undefined reference to 'monodroid_typemap_managed_to_java'
E:\Unity Projects\Racing Game\Temp\StagingArea\Il2Cpp\il2cppOutput/Bulk_Mono.Android_0.cpp:13900: error: undefined reference to '_monodroid_gref_log'
E:\Unity Projects\Racing Game\Temp\StagingArea\Il2Cpp\il2cppOutput/Bulk_Mono.Android_0.cpp:14074: error: undefined reference to 'monodroid_typemap_managed_to_java'
E:\Unity Projects\Racing Game\Temp\StagingArea\Il2Cpp\il2cppOutput/Bulk_Mono.Android_1.cpp:13241: error: undefined reference to 'monodroid_typemap_java_to_managed'
E:\Unity Projects\Racing Game\Temp\StagingArea\Il2Cpp\il2cppOutput/Bulk_Mono.Android_1.cpp:13241: error: undefined reference to 'monodroid_typemap_java_to_managed'
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)
at il2cpp.Program.Run(String[] args)
at il2cpp.Program.Main(String[] args)
UnityEngine.Debug:LogError(Object)
UnityEditorInternal.Runner:RunProgram(Program, String, String, String, CompilerOutputParserBase) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildUtils.cs:128)
UnityEditorInternal.Runner:RunManagedProgram(String, String, String, CompilerOutputParserBase, Action1) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildUtils.cs:73)
UnityEditorInternal.IL2CPPBuilder:RunIl2CppWithArguments(List1, Action1, String) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:368)
UnityEditorInternal.IL2CPPBuilder:ConvertPlayerDlltoCpp(String, String, String, Boolean) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:349)
UnityEditorInternal.IL2CPPBuilder:Run() (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:211)
UnityEditorInternal.IL2CPPUtils:RunIl2Cpp(String, String, IIl2CppPlatformProvider, Action1, RuntimeClassRegistry) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:35)
UnityEditor.EditorApplication:Internal_CallGlobalEventHandler()```
Now that we have Barracuda replacing TensorFlowSharp, this issue is no longer valid. Since there is no activity to this issue, I will close it. Feel free to open if you want to discuss more.
Hi all my friend! I also faced with this problem, you can fix it like this -



Most helpful comment
Hey all, I came across this issue as well, we're really just using the implementation of TensorFlowSharp in our project. There were 2 issues, TensorFlowSharp.Android (or perhaps its dependencies) was causing IL2CPP builds to fail, and the TensorFlowSharp DLL had a runtime problem in it as well.
Turns out we didn't need anything to do with the Native Android Binding (it mostly looks to just provide logging..), so we could remove
TensorFlowSharp.Android.dll, and get rid of it's dependencies, as well as the rest of the DLL's since we were using .NET Standard 2.0 in our project. I also had to make a couple small tweaks to TensorFlowSharp.So for those of you having this issue using TensorFlowSharp with IL2CPP:
ML-Agents/Plugins/Android1.7.0-il2cpp(you can see my changes here)ML-Agents/Plugins/Android, make sure it's only accessible from Android buildsTensorFlowSharp has since fixed this, but the native binaries in ML-Agents use TF 1.7, and TF# 1.7 has this bug.