2014-02-28 56 views
1

我的Play-Console中有一個奇怪的StackTrace - 我無法重現該問題,它不直接在我的代碼中產生。也許這裏有人有一個關於如何處理這個問題的想法,而不是忽略它。雖然發生過一次 - 但我真的很想知道那裏發生了什麼。ListPreference中的ArrayIndexOutOfBoundsException

java.lang.ArrayIndexOutOfBoundsException: length=3; index=3 
    at android.preference.ListPreference.getEntry(ListPreference.java:203) 
    at android.preference.ListPreference.getSummary(ListPreference.java:148) 
    at android.preference.Preference.onBindView(Preference.java:522) 
    at android.preference.Preference.getView(Preference.java:460) 
    at android.preference.PreferenceGroupAdapter.getView(PreferenceGroupAdapter.java:221) 
    at android.widget.AbsListView.obtainView(AbsListView.java:2308) 
    at android.widget.ListView.makeAndAddView(ListView.java:2030) 
    at android.widget.ListView.fillDown(ListView.java:822) 
    at android.widget.ListView.fillFromTop(ListView.java:883) 
    at android.widget.ListView.layoutChildren(ListView.java:1848) 
    at android.widget.AbsListView.onLayout(AbsListView.java:2136) 
    at android.view.View.layout(View.java:14177) 
    at android.view.ViewGroup.layout(ViewGroup.java:4399) 
    at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1663) 
    at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1521) 
    at android.widget.LinearLayout.onLayout(LinearLayout.java:1434) 
    at android.view.View.layout(View.java:14177) 
    at android.view.ViewGroup.layout(ViewGroup.java:4399) 
    at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1663) 
    at android.widget.LinearLayout.layoutHorizontal(LinearLayout.java:1652) 
    at android.widget.LinearLayout.onLayout(LinearLayout.java:1436) 
    at android.view.View.layout(View.java:14177) 
    at android.view.ViewGroup.layout(ViewGroup.java:4399) 
    at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1663) 
    at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1521) 
    at android.widget.LinearLayout.onLayout(LinearLayout.java:1434) 
    at android.view.View.layout(View.java:14177) 
    at android.view.ViewGroup.layout(ViewGroup.java:4399) 
    at android.widget.FrameLayout.onLayout(FrameLayout.java:448) 
    at android.view.View.layout(View.java:14177) 
    at android.view.ViewGroup.layout(ViewGroup.java:4399) 
    at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1663) 
    at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1521) 
    at android.widget.LinearLayout.onLayout(LinearLayout.java:1434) 
    at android.view.View.layout(View.java:14177) 
    at android.view.ViewGroup.layout(ViewGroup.java:4399) 
    at android.widget.FrameLayout.onLayout(FrameLayout.java:448) 
    at android.view.View.layout(View.java:14177) 
    at android.view.ViewGroup.layout(ViewGroup.java:4399) 
    at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2244) 
    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2017) 
    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1190) 
    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4860) 
    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:766) 
    at android.view.Choreographer.doCallbacks(Choreographer.java:575) 
    at android.view.Choreographer.doFrame(Choreographer.java:542) 
    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:751) 
    at android.os.Handler.handleCallback(Handler.java:725) 
    at android.os.Handler.dispatchMessage(Handler.java:92) 
    at android.os.Looper.loop(Looper.java:158) 
    at android.app.ActivityThread.main(ActivityThread.java:5751) 
    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:1083) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:850) 
    at dalvik.system.NativeStart.main(Native Method) 
+0

請檢查您在ListPref中使用的ArrayList的大小是否有錯誤...? –

+0

@ligi你是否也可以發佈用於設置列表的偏好設置的XML? – JJD

+0

我也只在某個設備上面對同樣模糊的異常 - 在所有其他設備上它工作正常。將不勝感激帖子的進展。 – SirKnigget

回答

1

每當你嘗試訪問是在ArrayList中的範圍(超出大小)或不一般發生java.lang.ArrayIndexOutOfBoundsException:錯誤。

因此,從錯誤中可以看出java.lang.ArrayIndexOutOfBoundsException: length=3; index=3有時會發生這種情況,即您嘗試訪問的數值大於數組的大小。由於您的數組列表只包含總共3條記錄,因爲您可能試圖訪問3位置的索引。而數組開始從索引「0」開始計數它的值,所以會有像0,1,2...這樣的值,所以在這種情況下,它將無法獲得索引「3」處的值不可用。

所以"java.lang.ArrayIndexOutOfBoundsException: length=3; index=3"。這意味着您請求的索引超出了數組的範圍。換句話說,數組有一個長度(這是界限)。當它的長度是3(它是空的)並且你要求第3個元素時,數組告訴你你請求的項目不可用,因爲該數組甚至不是3個元素。

相關問題