Bavilo
Bavilo

Reputation: 409

Android - Array index Out Of bounds but why?

One of my users is experiencing a problem with my app. I have received he stack trace but it's not really pointing me to the problem. All I knoe is that some index is out of bounds, but which index? The trace does not lead me to my code...

I believe I have had this in the past, I might have solved it by disabling minifyEnabled and shrinkResources. These options are enabled again but on my Nexus 6P the app is working fine.

Here the stack trace:

Android-Version

Android 4.0.3 - 4.0.4 1 Iconia Tab A501 (picasso) 1

java.lang.ArrayIndexOutOfBoundsException: length=7; index=7
    at com.baviloworks.braumeister.f.m(Unknown Source)
at com.baviloworks.braumeister.f$1.onClick(Unknown Source)
at android.view.View.performClick(View.java:3511)
at android.view.View$PerformClick.run(View.java:14110)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at     com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(Zygote    Init.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)

I hope someone knows what this could be.

Thanks!

Upvotes: 0

Views: 1390

Answers (2)

Dima
Dima

Reputation: 443

The stack trace is obfuscated, so first of all we have to decode it so we get the actual file where the exception is thrown:

Launch Android/Sdk/tools/proguard/bin/proguardgui.bat (or .sh if you are on Linux), select Retrace on the left side and then select your mapping.txt.

See http://simplyadvanced.net/blog/android-how-to-decode-proguards-obfuscated-code-from-stack-trace/

Upvotes: 2

Charuka Silva
Charuka Silva

Reputation: 13153

An Array length of 7 means that only the index 6 exist from 0, because in java array indexes start with 0! So this will work till you index to 6

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

Upvotes: 0

Related Questions