- Home /
ArgumentOutOfRangeException with no script reference Android
I receive this error when i try to build an Android apk. My app runs in the Unity editor, though... There is no line reference for the error. I am not sure where to begin tracking this...
Exception: Error building Player: ArgumentOutOfRangeException: Index is less than 0 or more than or equal to the list count. Parameter name: index 0 UnityEditor.BuildPlayerWindow.BuildPlayerWithDefaultSettings (Boolean askForBuildLocation, BuildOptions forceOptions) UnityEditor.BuildPlayerWindow.GUIBuildButtons (Boolean enableBuildButton, Boolean enableBuildAndRunButton, Boolean canInstallInBuildFolder) UnityEditor.BuildPlayerWindow.ShowBuildTargetSettings () UnityEditor.BuildPlayerWindow.OnGUI () System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation. System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) UnityEditor.HostView.Invoke (System.String methodName) UnityEditor.HostView.OnGUI ()
Answer by BiG · Feb 02, 2012 at 10:03 AM
You've received "Index is less than 0 or more than or equal to the list count" notification, on a variable called index. It seems that you are trying to access an illegal index for an array (in fact, look at the third row of the compiler's result: it's "0" - the index's value -, and that's not legal for an array).
Try to search for all the occurrencies of "index" in your scripts, and watch out for suspicious decrements of that variable (maybe you have a for loop that performs more than the desired steps).
The odd part was that I did a search thru files and I don't have a single variable named index. It turned out to be due to not defining a Dictionary parameter with explicit types in a method. http://forum.unity3d.com/threads/121720-ArgumentOutOfRangeException-with-no-line-references
Answer by ina2 · Feb 05, 2012 at 10:33 PM
FYI, this error also occurs when MonoBehaviour expects a type declaration for Dictionary in parameter of a method. Yes, the error does NOT mention any line numbers.
function blah(dic:Dictionary) instead of function blah(dictionary:Dictionary.<String,String>)
I wonder if there is an easier way to catch this kind of error in the future.