Forum Xamarin.Forms

[Android]Java.Lang.ArrayIndexOutOfBoundsException thrown when using the custom library.


I am trying to run the custom library in VS 2019 Mac with Android version 7.1 but i am getting the following exception. Please suggest me how to resolve this.

My code:

TypedArray styledAttrs = context.Theme.ObtainStyledAttributes(attributes, Resource.Styleable.CustomControl, styleAttributes, styleRes);
scale.StartAngle = styledAttrs.GetFloat(Resource.Styleable.StartAngle, (float)scale.StartAngle);


Java.Lang.ArrayIndexOutOfBoundsException: length=636; index=720
at Java.Interop.JniEnvironment+InstanceMethods.CallFloatMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00069] in <3f0dfed935344816aef2b177cb7cdcaa>:0
at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualSingleMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x0002a] in <3f0dfed935344816aef2b177cb7cdcaa>:0
at Android.Content.Res.TypedArray.GetFloat (System.Int32 index, System.Single defValue) [0x00035] in <4c3a009e1b504a10bee066556d7ee14a>:0


  • AnubhavRanjanAnubhavRanjan INXamarin Team Xamurai

    @SanthiyaArulsamy Well I can take a guess that the exception is clearly mentioning the total length as 636 and index being asked is 720, which seems to be throwing the Java.Lang.ArrayIndexOutOfBoundsException

    I would suggest to contain this in a small sample and share it with us.
    If needed feel free to open a ticket with us.





    Looking for Free* Microsoft Support on Xamarin Issues, visit

  • SanthiyaArulsamySanthiyaArulsamy INMember ✭✭
    edited July 2019

    @AnubhavRanjan Thanks.. but the stack trace showing the issue from frame work. In my sample, i am just passing

    scale.StartAngle = styledAttrs.GetFloat(1,180);

    Can you tell me the meaning of this "length=636; index=720 "?

  • JarvanJarvan Member, Xamarin Team Xamurai

    An ArrayIndexOutOfBoundsException is thrown when an out-of-range index is detected by an array object. An out-of-range index occurs when the index is less than zero or greater than or equal to the size of the array.

Sign In or Register to comment.