Android Question Runtime error

pjetson

Member
Licensed User
Longtime User
I have been testing my app "in the field", and when I pulled my phone out of my pocket a few minutes ago, there was a runtime error on the screen. The error says:

An error has occured in sub: java.lang.StringIndexOutOfBoundsException: length=38; regionStart=8; regionLength=-6

Now, it appears that the error is probably the -6, but how do I work out where the error is occurring in my app? This error has never occurred while my phone has been plugged into the PC, at least so far.

There is in fact one place in my code where I use SubString2(8, 2) and that kind of matches the java exception name. The first SubString2 parameter of 8 matches the regionStart parameter, but the length parameter is 2 and both parameters are always integer constants.
 

pjetson

Member
Licensed User
Longtime User
Oops - I just wrote some test code, and it displayed the message "You are an idiot".

I thought the second parameter to SubString2 was a length, but it's actually an index. My code should say SubString2(8,10)
 
Upvote 0
Top