2016-09-05 4 views
1

Ich bekomme diese Ausnahme auf einigen Geräten und ich weiß nicht, was es verursacht.Android Snackbar verursacht IndexOutOfBoundsException

java.util.ArrayList.throwIndexOutOfBoundsException (ArrayList.java:255) 
java.util.ArrayList.get (ArrayList.java:308) 
android.support.design.widget.CoordinatorLayout.onChildViewsChanged (CoordinatorLayout.java:1225) android.support.design.widget.CoordinatorLayout$HierarchyChangeListener.onChildViewRemoved (CoordinatorLayout.java:2863) 
android.view.ViewGroup.dispatchViewRemoved (ViewGroup.java:4226) 
android.view.ViewGroup.removeViewInternal (ViewGroup.java:4627) 
android.view.ViewGroup.removeViewInternal (ViewGroup.java:4582) 
android.view.ViewGroup.removeView (ViewGroup.java:4513) 
android.support.design.widget.Snackbar.onViewHidden (Snackbar.java:646) 
android.support.design.widget.Snackbar.access$300 (Snackbar.java:72) 
android.support.design.widget.Snackbar$9.onAnimationEnd (Snackbar.java:588) 
android.support.v4.view.ViewPropertyAnimatorCompatJB$1.onAnimationEnd (ViewPropertyAnimatorCompatJB.java:47) 
android.view.ViewPropertyAnimator$AnimatorEventListener.onAnimationEnd (ViewPropertyAnimator.java:1114) 
android.animation.ValueAnimator.endAnimation (ValueAnimator.java:1239) 
android.animation.ValueAnimator$AnimationHandler.doAnimationFrame (ValueAnimator.java:766) 
android.animation.ValueAnimator$AnimationHandler$1.run (ValueAnimator.java:801) 
android.view.Choreographer$CallbackRecord.run (Choreographer.java:873) 
android.view.Choreographer.doCallbacks (Choreographer.java:676) 
android.view.Choreographer.doFrame (Choreographer.java:603) 
android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:859) 
android.os.Handler.handleCallback (Handler.java:739) 
android.os.Handler.dispatchMessage (Handler.java:95) 
android.os.Looper.loop (Looper.java:168) 
android.app.ActivityThread.main (ActivityThread.java:5845) 
java.lang.reflect.Method.invoke (Method.java) 
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:797) 
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:687) 

Ich habe eine activity_main XML-Datei mit einem auf einem app_bar_main.xml umfassen, die eine content_mail XML-Datei enthält.

activity_main.xml

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/drawer_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true" 
    tools:openDrawer="start"> 

    <include 
     layout="@layout/app_bar_main" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" /> 

    <android.support.design.widget.NavigationView 
     android:id="@+id/nav_view" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     android:fitsSystemWindows="true" 
     app:headerLayout="@layout/nav_header_main" 
     app:menu="@menu/activity_main_drawer" /> 

</android.support.v4.widget.DrawerLayout> 

app_bar_main.xml

<?xml version="1.0" encoding="utf-8"?> 
<android.support.design.widget.CoordinatorLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/bar_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true" 
    tools:context=".application.activities.MainActivity"> 

    <android.support.design.widget.AppBarLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:theme="@style/AppTheme.AppBarOverlay"> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:background="?attr/colorPrimary" 
      app:popupTheme="@style/AppTheme.PopupOverlay" /> 

    </android.support.design.widget.AppBarLayout> 

    <include layout="@layout/content_main" /> 

</android.support.design.widget.CoordinatorLayout> 

content_main.xml

<?xml version="1.0" encoding="utf-8"?> 
<android.support.design.widget.CoordinatorLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" 
    tools:context=".application.activities.MainActivity" 
    tools:showIn="@layout/app_bar_main"> 

    <android.support.design.widget.CoordinatorLayout 
     android:id="@+id/container" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" /> 

</android.support.design.widget.CoordinatorLayout> 

Ich mache die Snackbar auf der Standard-Inhaltsansicht, aber in fast zufälligen Momenten stürzt sie wegen der Ausnahme ab. Das Seltsame ist, dass ich auf meinen eigenen Geräten/Emulatoren den Fehler nicht reproduzieren kann (obwohl ich es zuerst reproduzieren konnte, aber ich änderte die Ansicht der Snackbar in android.R.id.content und dann hörte es auf meinen Geräten auf) . Aber auf anderen Geräten wie einem HTC M8 (Android 6.0) von einem Freund von mir erscheint die Ausnahme.

Snackbar.make(findViewById(android.R.id.content), "Updating " + info.type, Snackbar.LENGTH_LONG).show(); 

UPDATE 1: Similiar Probleme gefunden

+0

Haben Sie versucht, [diese] (http://stackoverflow.com/questions/30986163/arrayindexoutofboundsexception-while-dismissing-snackbar-viewdraghelper) – Shaishav

+0

@Shaishav Ja, in der im Lieferumfang enthaltenen Code verwende ich 'Snackbar.make (findViewById (android.R.id.content), "Aktualisierung" + info.type, Snackbar.LENGTH_LONG); ' –

Antwort

0

ich meine Probleme gelöst haben, auf eine ältere Android Support Library Version (v24 durch Herabstufung. 1.1). Sehen Sie sich den Android Issue Tracker here an.

UPDATE 1: Scheint, wie es in de nächsten Version des Android-Support Library (v24.2.1)

UPDATE 2 aufgelöst werden wird: 24.2.1 ist, wie von heute und den Fehler scheint aufgelöst zu sein - zumindest konnte ich es mit der aktuellen Version nicht reproduzieren. - PattaFeuFeu

Verwandte Themen