How to fix java.lang.ArrayIndexOutOfBoundsException: length=1; index=1

↘锁芯ラ 提交于 2019-12-05 18:04:23

An Array length of 1 means that only the index 0 exist, because in java array indexes start with 0!

Or in other words the Boundaries of an Array are Array.length -1

Moataz Shawky

length = 1 means that the array has only 1 element in it, and java is zero based numbering (which means that indexing an array starts from 0 not 1).

since you have only one element in the array, this means that you need to access it with index = 0 , not index = 1

this is what the error trying to tell you.

syed99

The Logcat indicates you are having error at line 74 in UsbDriver Class at:

if (!conn.claimInterface(Device_Details.getInterface(1), true)) { ...}

try replacing with 0 in the place of 1.

I don't know why you hardcoded this with 1.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!