Description
My code is working fine on Android, with Mono, and on iOS with il2cpp but I wanted to try compiling my Unity game on Android with il2cpp, as it is now supported, but I have encountered an error which causes the UnityMainThreadDispatcher to be null.
In my GameController object I have a script which attaches the UnityInitialiser to itself, as instructed:
UnityInitializer.AttachToGameObject(gameObject);
Compiling this and running it will cause this exception to occur:
I/Unity ( 7756): (Filename: ./artifacts/generated/Android/runtime/UnityEngineDebugBindings.gen.cpp Line: 45)
I/Unity ( 7756):
I/Unity ( 7756): ExecutionEngineException: Attempting to call method 'UnityEngine.AndroidJavaObject::Get' for which no ahead of time (AOT) code was generated.
I/Unity ( 7756):
I/Unity ( 7756): Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
Which disrupts the initialisation and UnityMainThreadDispatcher is not correctly added as a component to my GameController. (It will be null if I attempt to retrieve it).
Searching about this error lead me to this (CTRL+F "ExecutionEngineException") if that helps.
It is hard for me to debug this more as I am just using the provided DLLs on a non-Windows machine. I am guessing this is just a case of Android il2cpp not being supported, if that is the case then I hope it will be supported in the future.