Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Unity compilation and Android

Problems with Unity app compilation

While development of our API.AI Unity SDK I have faced with upset thing. When trying to build sample Unity app for iOS platform build ends with error:

Cross compilation job ApiAiSDK.Unity.dll failed.
UnityEngine.UnityException: Failed AOT cross compiler: /Applications/Unity/ --aot=full,asmonly,nodebug,static,outfile="ApiAiSDK.Unity.dll.s" "ApiAiSDK.Unity.dll" 

First I thought, that this situation is caused by external dll's, linked to the ApiAiSDK.Unity.dll library. Googling did not lead to anything useful... So I tried to check my external libraries, and run mono-xcompiler manually. mono-xcompiler compiles .NET Assembly to the native iOS code.

It was intresting, that another libraries was compiled with mono-xcompiler without problems, but ApiAiSDK.Unity.dll cause error:

Mono Ahead of Time compiler - compiling assembly ApiAiSDK.Unity.dll
The class UnityEngine.AndroidJavaObject could not be loaded, used in UnityEngine, Version=, Culture=neutral, PublicKeyToken=null
Missing method GetStatic in assembly ApiAiSDK.Unity.dll, type UnityEngine.AndroidJavaObject
[1]    93561 segmentation fault   --aot=full,asmonly,nodebug,static,outfile="ApiAiSDK.Unity.dll.s"

So, you see, that problems with project compilation was caused by the Unity class AndroidJavaObject, used for native Android interoperability. This classes should be placed in the code snippet like

      // your code...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment