Android Question Error: java.lang.ArrayIndexOutOfBoundsException

slugger

Member
Licensed User
Longtime User
Hi,

in the logs panel I have seen the following error:

B4X:
java.lang.ArrayIndexOutOfBoundsException: length=12; index=-1

I have 2 problems with that:

1. it seems to appear randomly from time to time, I haven't been able to reproduce it
2. that is the only red line showing up in the Logs panel, usually I get a bunch of red lines with an indication of the line of code which generates the error, in this case I get only that single line.

I use the IDE in Debug (legacy) mode.

My app seems to run fine, I haven't had any crashes nor unexpected breakpoints in the IDE but I'd still like to get rid of that error message.

Any hints on how I can track down the line that generates that error?


Thank you in advance.
 

slugger

Member
Licensed User
Longtime User
Hi Erel,

exactly, that's all I see.

This is a sequential extract of what I read on the Logs tab:

B4X:
** Activity (main) Pause, UserClosed = true **
java.lang.ArrayIndexOutOfBoundsException: length=12; index=-1
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **

Nothing in the middle, just that line.

I don't get any info on the line where the error is generated, not even a hint on what component is causing the error message to show up.
 
Upvote 0

slugger

Member
Licensed User
Longtime User
Are you using Try / Catch somewhere and printing the error?

No, all my Try - Catch blocks end like this:

B4X:
        Catch
            Log("Error 2: "&LastException.Message)
            generalError=True   
        End Try

Have you checked the unfiltered logs?

I haven't thought about that, next time I'll see the error I'll uncheck the Filter box.

It is possible that this error happens inside a library which catches it.

I hope it's nothing serious, as I said it seems it hasn't created problems to my program so far.



steve
 
Upvote 0

paris7162

Member
Licensed User
Longtime User
I've been noticing it lately also, however, I largely ignore it. When I uncheck the Filter box on the Logs tab, it still only shows java.lang.ArrayIndexOutOfBoundsException: length=12; index=-1 with nothing else.


** Activity (main) Pause, UserClosed = true **
Installing file.
GC_FOR_ALLOC freed 812K, 13% free 7950K/9040K, paused 20ms, total 20ms
GC_CONCURRENT freed 24K, 8% free 8334K/9040K, paused 3ms+1ms, total 22ms
GC_FOR_ALLOC freed 733K, 13% free 7910K/9040K, paused 21ms, total 21ms
GC_CONCURRENT freed 394K, 13% free 7918K/9040K, paused 4ms+2ms, total 28ms
GC_CONCURRENT freed 418K, 13% free 7926K/9040K, paused 6ms+2ms, total 33ms
GC_CONCURRENT freed 418K, 13% free 7918K/9040K, paused 3ms+2ms, total 32ms
GC_CONCURRENT freed 386K, 13% free 7926K/9040K, paused 3ms+2ms, total 22ms
GC_CONCURRENT freed 410K, 13% free 7918K/9040K, paused 2ms+2ms, total 19ms
GC_CONCURRENT freed 410K, 13% free 7934K/9040K, paused 7ms+3ms, total 35ms
PackageAdded: package:tonk.classic
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Pause, UserClosed = false **
java.lang.ArrayIndexOutOfBoundsException: length=12; index=-1
Ignoring event:
** Activity (main) Resume **
** Activity (main) Resume **
received
GC_CONCURRENT freed 415K, 13% free 7902K/8992K, paused 9ms+1ms, total 31ms
Installing file.
GC_CONCURRENT freed 411K, 8% free 7918K/8588K, paused 8ms+1ms, total 51ms
GC_FOR_ALLOC freed 273K, 8% free 7910K/8588K, paused 24ms, total 24ms
GC_FOR_ALLOC freed 265K, 8% free 7918K/8588K, paused 20ms, total 20ms
GC_FOR_ALLOC freed 273K, 8% free 7910K/8588K, paused 18ms, total 18ms
GC_FOR_ALLOC freed 273K, 8% free 7910K/8588K, paused 22ms, total 22ms
GC_FOR_ALLOC freed 273K, 8% free 7910K/8588K, paused 26ms, total 26ms
GC_FOR_ALLOC freed 273K, 8% free 7910K/8588K, paused 23ms, total 23ms
GC_FOR_ALLOC freed 273K, 8% free 7910K/8588K, paused 24ms, total 24ms
GC_FOR_ALLOC freed 265K, 8% free 7918K/8588K, paused 26ms, total 26ms
GC_FOR_ALLOC freed 273K, 8% free 7910K/8588K, paused 26ms, total 26ms
GC_FOR_ALLOC freed 273K, 8% free 7910K/8588K, paused 20ms, total 20ms
GC_FOR_ALLOC freed 273K, 8% free 7910K/8588K, paused 26ms, total 26ms
PackageAdded: package:tonk.classic
** Activity (main) Create, isFirst = true **
GC_FOR_ALLOC freed 307K, 8% free 7902K/8588K, paused 23ms, total 23ms
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
Ignoring event:
** Activity (main) Resume **
** Activity (main) Resume **
received
received
 
Upvote 0

eps

Expert
Licensed User
Longtime User
Could it be something to do with Months? The length of the array is 12, seemingly in both cases, but the index has gone past that...

I haven't seen this error, but I haven't been doing that much B4A development in the past 2-3 months.

What version of B4A are people seeing this in? The latest one?
 
Upvote 0

KMatle

Expert
Licensed User
Longtime User
Had the little "error" a few minutes ago. It's in rapid debug and when you add/change some lines to the code while the debugger is "running". Pressing the restart button then sometimes causes it.

Maybe new lines are not updated while restarting (example: before 20 and after 23. The 3 new lines are not seen yet but addressed = out of bounds)
 
Upvote 0
Top