- Home /
IL2CPP error on Unity5
Been bashing my head for the past few days trying to port my droid app to iOS.
Most of the code is in-house, just using UnityAds, SIS (Simple IAP System) and GooglePlayGames plugins.
With IL2CCP on, it won't even build on Unity 5 (latest version). I get the following errors:
IL2CPP error for type 'GooglePlayGames.Native.PInvoke.PInvokeUtilities/OutStringMethod' in assembly '/Temp/StagingArea/Data/Managed/Assembly-CSharp.dll'
Additional information: Build a development build for more information. Exception has been thrown by the target of an invocation.
Failed running /Applications/Unity/Unity.app/Contents/Frameworks/il2cpp/il2cpp.exe --copy-level=None --enable-generic-sharing --enable-unity-event-support --emit-null-checks --enable-array-bounds-check --enable-symbol-loading
"/Temp/StagingArea/Data/Managed/Assembly-CSharp-firstpass.dll"
"/Temp/StagingArea/Data/Managed/Assembly-CSharp.dll"
"/Temp/StagingArea/Data/Managed/Assembly-UnityScript.dll"
"/Temp/StagingArea/Data/Managed/UnityEngine.UI.dll" "/Temp/StagingArea/Data/Managed/OpenIAB_W8Plugin.dll" "/Temp/StagingArea/Data/Managed/UnityEngine.Cloud.Analytics.dll"
"/Temp/il2cppOutput/il2cppOutput"
stdout:
IL2CPP error for type 'GooglePlayGames.Native.PInvoke.PInvokeUtilities/OutStringMethod' in assembly '/Temp/StagingArea/Data/Managed/Assembly-CSharp.dll'
Additional information: Build a development build for more information. Exception has been thrown by the target of an invocation.
stderr:
Unhandled Exception:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidCastException: Cannot cast from source type to destination type.
at Unity.IL2CPP.IncludeCollection.NonTemplated.TypeDefinitionVisitor.HandleDelegate (Mono.Cecil.TypeDefinition typeDefinition) [0x00000] in <filename unknown>:0
at Unity.IL2CPP.IncludeCollection.NonTemplated.TypeDefinitionVisitor.Visit (Mono.Cecil.TypeDefinition typeDefinition, Unity.Cecil.Visitor.Context context) [0x00000] in <filename unknown>:0
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <filename unknown>:0
at Unity.Cecil.Visitor.Visitor.Visit[TypeDefinition] (Mono.Cecil.TypeDefinition node, Unity.Cecil.Visitor.Context context) [0x00000] in <filename unknown>:0
at Unity.Cecil.Visitor.Extensions.DoAccept[TypeDefinition] (Mono.Cecil.TypeDefinition definition, Unity.Cecil.Visitor.Visitor visitor) [0x00000] in <filename unknown>:0
at Unity.Cecil.Visitor.Extensions.Accept (Mono.Cecil.TypeDefinition typeDefinition, Unity.Cecil.Visitor.Visitor visitor) [0x00000] in <filename unknown>:0
at Unity.IL2CPP.IncludeCollection.NonTemplated.IncludeCollector.ForTypeDefinition (Mono.Cecil.TypeDefinition type) [0x00000] in <filename unknown>:0
at Unity.IL2CPP.IncludeCollection.NonTemplated.IncludeCollector.ForTypeDefinition (Mono.Cecil.TypeReference type) [0x00000] in <filename unknown>:0
at Unity.IL2CPP.IncludeWriter.WriteTypeDefinitionIncludes (Mono.Cecil.TypeReference type, Unity.IL2CPP.CppCodeWriter writer) [0x00000] in <filename unknown>:0
at Unity.IL2CPP.SourceWriter.WriteTypeDefinitionFor (System.String outputDirectory, Mono.Cecil.TypeReference type) [0x00000] in <filename unknown>:0
at Unity.IL2CPP.SourceWriter.Write (Mono.Cecil.AssemblyDefinition assemblyDefinition, Unity.IL2CPP.GenericsCollection.InflatedCollection allGenerics, System.String outputDir, Mono.Cecil.TypeDefinition[] typeList, Unity.IL2CPP.StringLiterals.StringLiteralCollection stringLiteralCollection) [0x00000] in <filename unknown>:0
at Unity.IL2CPP.AssemblyConverter.Convert (Mono.Cecil.AssemblyDefinition assemblyDefinition, Unity.IL2CPP.StringLiterals.StringLiteralCollection stringLiteralCollection, Unity.IL2CPP.GenericsCollection.InflatedCollection allGenerics) [0x00000] in <filename unknown>:0
at Unity.IL2CPP.AssemblyConverter.Apply () [0x00000] in <filename unknown>:0
at Unity.IL2CPP.AssemblyConverter.ConvertAssemblies (System.String[] assemblies, System.String outputDir) [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidCastException: Cannot cast from source type to destination type.
at Unity.IL2CPP.IncludeCollection.NonTemplated.TypeDefinitionVisitor.HandleDelegate (Mono.Cecil.TypeDefinition typeDefinition) [0x00000] in <filename unknown>:0
at Unity.IL2CPP.IncludeCollection.NonTemplated.TypeDefinitionVisitor.Visit (Mono.Cecil.TypeDefinition typeDefinition, Unity.Cecil.Visitor.Context context) [0x00000] in <filename unknown>:0
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <filename unknown>:0
at Unity.Cecil.Visitor.Visitor.Visit[TypeDefinition] (Mono.Cecil.TypeDefinition node, Unity.Cecil.Visitor.Context context) [0x00000] in <filename unknown>:0
at Unity.Cecil.Visitor.Extensions.DoAccept[TypeDefinition] (Mono.Cecil.TypeDefinition definition, Unity.Cecil.Visitor.Visitor visitor) [0x00000] in <filename unknown>:0
at Unity.Cecil.Visitor.Extensions.Accept (Mono.Cecil.TypeDefinition typeDefinition, Unity.Cecil.Visitor.Visitor visitor) [0x00000] in <filename unknown>:0
at Unity.IL2CPP.IncludeCollection.NonTemplated.IncludeCollector.ForTypeDefinition (Mono.Cecil.TypeDefinition type) [0x00000] in <filename unknown>:0
at Unity.IL2CPP.IncludeCollection.NonTemplated.IncludeCollector.ForTypeDefinition (Mono.Cecil.TypeReference type) [0x00000] in <filename unknown>:0
at Unity.IL2CPP.IncludeWriter.WriteTypeDefinitionIncludes (Mono.Cecil.TypeReference type, Unity.IL2CPP.CppCodeWriter writer) [0x00000] in <filename unknown>:0
at Unity.IL2CPP.SourceWriter.WriteTypeDefinitionFor (System.String outputDirectory, Mono.Cecil.TypeReference type) [0x00000] in <filename unknown>:0
at Unity.IL2CPP.SourceWriter.Write (Mono.Cecil.AssemblyDefinition assemblyDefinition, Unity.IL2CPP.GenericsCollection.InflatedCollection allGenerics, System.String outputDir, Mono.Cecil.TypeDefinition[] typeList, Unity.IL2CPP.StringLiterals.StringLiteralCollection stringLiteralCollection) [0x00000] in <filename unknown>:0
at Unity.IL2CPP.AssemblyConverter.Convert (Mono.Cecil.AssemblyDefinition assemblyDefinition, Unity.IL2CPP.StringLiterals.StringLiteralCollection stringLiteralCollection, Unity.IL2CPP.GenericsCollection.InflatedCollection allGenerics) [0x00000] in <filename unknown>:0
at Unity.IL2CPP.AssemblyConverter.Apply () [0x00000] in <filename unknown>:0
at Unity.IL2CPP.AssemblyConverter.ConvertAssemblies (System.String[] assemblies, System.String outputDir) [0x00000] in <filename unknown>:0
UnityEngine.Debug:LogError(Object)
UnityEditorInternal.Runner:RunManagedProgram(String, String, String, CompilerOutputParserBase) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:66)
UnityEditorInternal.IL2CPPBuilder:ConvertPlayerDlltoCpp(ICollection`1, String, String) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:404)
UnityEditorInternal.IL2CPPBuilder:Run() (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:275)
UnityEditorInternal.IL2CPPUtils:RunIl2Cpp(String, String, IIl2CppPlatformProvider, Action`1, RuntimeClassRegistry) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:211)
UnityEditor.HostView:OnGUI()[/code]
Exception: /Applications/Unity/Unity.app/Contents/Frameworks/il2cpp/il2cpp.exe did not run properly!
UnityEditorInternal.Runner.RunManagedProgram (System.String exe, System.String args, System.String workingDirectory, UnityEditor.Scripting.Compilers.CompilerOutputParserBase parser) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:68)
UnityEditorInternal.IL2CPPBuilder.ConvertPlayerDlltoCpp (ICollection`1 userAssemblies, System.String outputDirectory, System.String workingDirectory) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:404)
UnityEditorInternal.IL2CPPBuilder.Run () (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:275)
UnityEditorInternal.IL2CPPUtils.RunIl2Cpp (System.String tempFolder, System.String stagingAreaData, IIl2CppPlatformProvider platformProvider, System.Action`1 modifyOutputBeforeCompile, UnityEditor.RuntimeClassRegistry runtimeClassRegistry) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:211)
UnityEditor.iOS.PostProcessiPhonePlayer.PostProcess (UnityEditor.iOS.iOSBuildPostprocessor pp, BuildTarget target, System.String stagingAreaData, System.String stagingArea, System.String stagingAreaDataManaged, System.String playerPackage, System.String installPath, System.String companyName, System.String productName, BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry)
UnityEditor.iOS.iOSBuildPostprocessor.PostProcess (BuildPostProcessArgs args)
UnityEditor.PostprocessBuildPlayer.Postprocess (BuildTarget target, System.String installPath, System.String companyName, System.String productName, Int32 width, Int32 height, System.String downloadWebplayerUrl, System.String manualDownloadWebplayerUrl, BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/PostprocessBuildPlayer.cs:316)
UnityEditor.HostView:OnGUI()
Error building Player: Exception: /Applications/Unity/Unity.app/Contents/Frameworks/il2cpp/il2cpp.exe did not run properly!
I've been stuck for a long time, hope you can help :)
Comment
Answer by JoshPeterson · Mar 27, 2015 at 08:56 AM
This should have been fixed in 5.0.0p2. However, 5.0.0p3 is now out as well, so please try that version.