Issue
I've tried to write my first serious android app and to list it on google play.
When I'm lancing my app for the first time, everything works fine. When I'm switching to another app, and then when I try to tun my app, I get the following codding error. I assume that is something bad with the path of my mp3 files that I'm using. i think it is related app activities life cycle. Can you tell me how can I simulate the activities life cycle on AVD ?
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.random12.soundtracks/com.random12.soundtracks.MenuActivity}: java.lang.IndexOutOfBoundsException: Invalid index 20, size is 7
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2078)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2103)
at android.app.ActivityThread.access$600(ActivityThread.java:137)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1211)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4839)
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(ZygoteInit.java:842)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IndexOutOfBoundsException: Invalid index 20, size is 7
at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:251)
at java.util.ArrayList.get(ArrayList.java:304)
at com.random12.soundtracks.MenuActivity.onCreate(Unknown Source)
at android.app.Activity.performCreate(Activity.java:5010)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2042)
... 11 more
I'm really new on writing java code and in using Eclipse based IDE's (adt bundle to be more specific)
Solution
Here's the thing. You say this: "I assume that is something bad with the path of my mp3 files that I'm using, when I have to deal with the activities life cycle."
You ABSOLUTELY don't need to assume. I think that you need to try to explore stack traces more, because the stack trace tells you exactly what's wrong, and typically, where it's wrong. Look at the very first link in what you posted from the crash. :
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.random12.soundtracks/com.random12.soundtracks.MenuActivity}: java.lang.IndexOutOfBoundsException: Invalid index 20, size is 7
When you see a runtimeexception, keep reading. We weren't able to start the activity - so it was probably had something to do with one of the early onCreate methods. Continuing on - "om.random12.soundtracks/com.random12.soundtracks.MenuActivity" It is in your MenuActivity class. Finally, we get to the meat and potatoes of the issue: java.lang.IndexOutOfBoundsException: Invalid index 20, size is 7
At some point when you try to open or reopen the MenuActivity class, you're trying to access an element in an array or some sort of indexed data structure that doesn't exist! There are only 7 elements in the arraything, and you're trying to access #20. Go check out for your code and see if you can figure out what the issue is. Or post part of it to here and I'll see if I can help.
The AVD simulates the events the same way a normal device would. You can still have apps running in the background, or closed and then reopened.
Answered By - Alex K
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.