4

我需要一些幫助來調試我的,並找出爲什麼我的android應用程序不斷崩潰。該應用程序在具有listview的頁面上崩潰,並且每個listview行都有一個圖像和一些文本。我創建了一個緩存類,用於在列表視圖中存儲所有圖像的位圖。在那個頁面上停留了一個小時(帶有列表視圖的頁面)之後,應用程序崩潰了,這就是我在Logcat控制檯中看到的內容。我無法理解這次事故是如何發生的,任何關於其根本原因的提示或任何建議都將非常有幫助。如果信息不足,我很抱歉。Android - E/Surface:queueBuffer:錯誤排隊緩衝區到SurfaceTexture,-22崩潰

07-21 00:47:07.143 2047-2423/com.app E/Parcel﹕ Parcel::writeDupFileDescriptor failed: 
    fd=931 flags=0 err=0(Success) 
    dupFd=-1 dupErr=24(Too many open files) flags=-1 err=9(Bad file number) 
07-21 00:47:07.172 2047-2423/com.app E/Surface﹕ queueBuffer: error queuing buffer to SurfaceTexture, -22 
07-21 00:47:07.172 2047-2423/com.app W/Adreno-EGLSUB﹕ <SwapBuffers:1344>: failed to queueBuffer 
07-21 00:47:07.172 2047-2423/com.app W/Adreno-EGL﹕ <qeglDrvAPI_eglSwapBuffers:3791>: EGL_BAD_SURFACE 
07-21 00:47:07.595 2047-2423/com.app E/Parcel﹕ Parcel::writeDupFileDescriptor failed: 

. (the same error as above gets repeated a couple of times) 
. 
. 

07-21 00:47:11.685 2047-2423/com.app W/Adreno-EGLSUB﹕ <SwapBuffers:1344>: failed to queueBuffer 
07-21 00:47:11.685 2047-2423/com.app W/Adreno-EGL﹕ <qeglDrvAPI_eglSwapBuffers:3791>: EGL_BAD_SURFACE 
07-21 00:47:12.128 2047-2423/com.app W/Adreno-GSL﹕ <gsl_ldd_control:416>: ioctl fd 28 code 0xc0140933 (IOCTL_KGSL_TIMESTAMP_EVENT) failed: errno 24 Too many open files 

. (the same error as above gets repeated a couple of times) 
. 
. 

07-21 00:47:17.839 2047-2047/com.app W/InputMethodManager﹕ IME died: com.android.inputmethod.latin/.LatinIME android.os.TransactionTooLargeException 

我也在我的XML佈局,如果這是任何有幫助的

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:id="@+id/framelayout" 
android:background="@color/black"> 

<ImageView 
    android:layout_width="225dp" 
    android:layout_height="225dp" 
    android:alpha="0.3" 
    android:id="@+id/background_image" 
    android:layout_gravity="center" 
    android:background="@drawable/visual_background_animation_list"/> 


<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/drawer_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_gravity="start"> 
    <!-- The main content view --> 
    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <RelativeLayout 
      android:id="@+id/top_header" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_alignParentTop="true" 
      android:background="@drawable/background_holo_dark"> 

      <ImageView 
       android:id="@+id/play_pause_button" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentLeft="true"/> 

      <SeekBar 
       android:layout_marginLeft="75dp" 
       android:id="@+id/seek_bar" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content"/> 

      <ImageView 
       android:id="@+id/nxt" 
       android:layout_width="60dp" 
       android:layout_height="60dp" 
       android:layout_alignParentRight="true"/> 

      <TextView 

       android:layout_alignLeft="@+id/nxt" 

       android:layout_below="@+id/seek_bar" 
       android:id="@+id/curr" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" /> 

      <TextView 

       android:layout_alignRight="@+id/nxt" 

       android:layout_below="@+id/seek_bar" 
       android:id="@+id/curr_2" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content"/> 

     </RelativeLayout> 

     <FrameLayout 
      android:id="@+id/content_frame" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_below="@id/top_header"> 

      <ListView 
       android:id="@+id/another_list" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent"/> 

     </FrameLayout> 


    </RelativeLayout> 

    <!-- The navigation drawer --> 

    <RelativeLayout 
     android:id="@+id/drawer" 
     android:layout_width="240dp" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     android:background="@android:color/darker_gray" 
     android:orientation="vertical"> 

     <ListView 
      android:id="@+id/another_list_2" 
      android:layout_width="240dp" 
      android:layout_height="match_parent" 
      android:layout_gravity="start" 
      android:choiceMode="singleChoice" /> 
    </RelativeLayout> 


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

我也想提一提,我有它運行,並正在顯示該應用程序的背景圖像動畫列表。抽屜式導航欄的

的Layout佈局導航抽屜

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 
<TableRow> 
    <TextView 
     android:id="@+id/name1"/> 
</TableRow> 
<TableRow> 
    <TextView 
     android:id="@+id/name2"/> 
</TableRow> 
</TableLayout> 

和列表視圖的佈局

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:visibility="invisible"> 


<ImageView 
    android:id="@+id/image_on_left" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" /> 

<RelativeLayout 
    android:id="@+id/relative_layout_id" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_toRightOf="@+id/image_on_left"> 

    <TextView 
     android:id="@+id/title1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" /> 

    <RelativeLayout 
     android:id="@+id/relative_layout_title2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/title1"> 

     <TextView 
      android:id="@+id/title2" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content"/> 

    </RelativeLayout> 

    <ImageView 
     android:id="@+id/another_image" 
     android:layout_alignParentRight="true"/> 
</RelativeLayout> 

</RelativeLayout> 
+0

你能提供代碼getView滿足在列表適配器? – Shakti

+0

@redsnowfox我添加了我的導航抽屜的佈局,也是列表視圖 – anonymous123

+0

我只是想檢查您是否正確地填充視圖。特別是你關閉你正在使用或不使用的打開的文件描述符。 – Shakti

回答

1

我沒發現

在網絡上,並在我的代碼和一些研究這是很多內存泄漏。我改變了一些東西來擺脫那個錯誤。

  1. 我確信,我的背景沒有被緩存在任何我的助手類(基本上是我的實用工具類)

  2. 而且我沒有使用一個holder類的在我的列表視圖

因此,我增加了以下聲明,我的自定義適配器類

static class ViewHolder { 
     TextView name; 
     ImageView imageView; 
    } 

@Override 
public View getView(int position, View convertView, ViewGroup parent) { 
    ViewHolder viewHolder = new ViewHolder(); 
    .... 
    convertView.setTag(viewHolder); 
}