2013-03-13 51 views
5

我在這個問題上經歷了幾個帖子,但沒有任何幫助。問題只發生在大屏幕設備上。以下是堆棧跟蹤。Android:InflateException:二進制XML文件行:錯誤膨脹類<unknown>

logcat的輸出

03-13 15:21:18.863: E/AndroidRuntime(6334): FATAL EXCEPTION: main 
03-13 15:21:18.863: E/AndroidRuntime(6334): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.dzo.seattlesnightlife/com.dzo.seattlesnightlife.StoreDescription}: android.view.InflateException: Binary XML file line #29: Error inflating class <unknown> 
03-13 15:21:18.863: E/AndroidRuntime(6334):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059) 
03-13 15:21:18.863: E/AndroidRuntime(6334):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084) 
03-13 15:21:18.863: E/AndroidRuntime(6334):  at android.app.ActivityThread.access$600(ActivityThread.java:130) 
03-13 15:21:18.863: E/AndroidRuntime(6334):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195) 
03-13 15:21:18.863: E/AndroidRuntime(6334):  at android.os.Handler.dispatchMessage(Handler.java:99) 
03-13 15:21:18.863: E/AndroidRuntime(6334):  at android.os.Looper.loop(Looper.java:137) 
03-13 15:21:18.863: E/AndroidRuntime(6334):  at android.app.ActivityThread.main(ActivityThread.java:4745) 
03-13 15:21:18.863: E/AndroidRuntime(6334):  at java.lang.reflect.Method.invokeNative(Native Method) 
03-13 15:21:18.863: E/AndroidRuntime(6334):  at java.lang.reflect.Method.invoke(Method.java:511) 
03-13 15:21:18.863: E/AndroidRuntime(6334):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) 
03-13 15:21:18.863: E/AndroidRuntime(6334):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 
03-13 15:21:18.863: E/AndroidRuntime(6334):  at dalvik.system.NativeStart.main(Native Method) 
03-13 15:21:18.863: E/AndroidRuntime(6334): Caused by: android.view.InflateException: Binary XML file line #29: Error inflating class <unknown> 
03-13 15:21:18.863: E/AndroidRuntime(6334):  at android.view.LayoutInflater.createView(LayoutInflater.java:613) 
03-13 15:21:18.863: E/AndroidRuntime(6334):  at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56) 
03-13 15:21:18.863: E/AndroidRuntime(6334):  at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660) 
03-13 15:21:18.863: E/AndroidRuntime(6334):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685) 
03-13 15:21:18.863: E/AndroidRuntime(6334):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:746) 
03-13 15:21:18.863: E/AndroidRuntime(6334):  at android.view.LayoutInflater.parseInclude(LayoutInflater.java:805) 
03-13 15:21:18.863: E/AndroidRuntime(6334):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:736) 
03-13 15:21:18.863: E/AndroidRuntime(6334):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:749) 
03-13 15:21:18.863: E/AndroidRuntime(6334):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:749) 
03-13 15:21:18.863: E/AndroidRuntime(6334):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:749) 
03-13 15:21:18.863: E/AndroidRuntime(6334):  at android.view.LayoutInflater.inflate(LayoutInflater.java:489) 
03-13 15:21:18.863: E/AndroidRuntime(6334):  at android.view.LayoutInflater.inflate(LayoutInflater.java:396) 
03-13 15:21:18.863: E/AndroidRuntime(6334):  at android.view.LayoutInflater.inflate(LayoutInflater.java:352) 
03-13 15:21:18.863: E/AndroidRuntime(6334):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256) 
03-13 15:21:18.863: E/AndroidRuntime(6334):  at android.app.Activity.setContentView(Activity.java:1867) 
03-13 15:21:18.863: E/AndroidRuntime(6334):  at com.dzo.seattlesnightlife.StoreDescription.init(StoreDescription.java:195) 
03-13 15:21:18.863: E/AndroidRuntime(6334):  at com.dzo.seattlesnightlife.StoreDescription.onCreate(StoreDescription.java:188) 
03-13 15:21:18.863: E/AndroidRuntime(6334):  at android.app.Activity.performCreate(Activity.java:5008) 
03-13 15:21:18.863: E/AndroidRuntime(6334):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079) 
03-13 15:21:18.863: E/AndroidRuntime(6334):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023) 
03-13 15:21:18.863: E/AndroidRuntime(6334):  ... 11 more 
03-13 15:21:18.863: E/AndroidRuntime(6334): Caused by: java.lang.reflect.InvocationTargetException 
03-13 15:21:18.863: E/AndroidRuntime(6334):  at java.lang.reflect.Constructor.constructNative(Native Method) 
03-13 15:21:18.863: E/AndroidRuntime(6334):  at java.lang.reflect.Constructor.newInstance(Constructor.java:417) 
03-13 15:21:18.863: E/AndroidRuntime(6334):  at android.view.LayoutInflater.createView(LayoutInflater.java:587) 
03-13 15:21:18.863: E/AndroidRuntime(6334):  ... 30 more 
03-13 15:21:18.863: E/AndroidRuntime(6334): Caused by: java.lang.OutOfMemoryError 
03-13 15:21:18.863: E/AndroidRuntime(6334):  at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method) 
03-13 15:21:18.863: E/AndroidRuntime(6334):  at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:500) 
03-13 15:21:18.863: E/AndroidRuntime(6334):  at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:353) 
03-13 15:21:18.863: E/AndroidRuntime(6334):  at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:781) 
03-13 15:21:18.863: E/AndroidRuntime(6334):  at android.content.res.Resources.loadDrawable(Resources.java:1930) 
03-13 15:21:18.863: E/AndroidRuntime(6334):  at android.content.res.Resources.getDrawable(Resources.java:659) 
03-13 15:21:18.863: E/AndroidRuntime(6334):  at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:173) 
03-13 15:21:18.863: E/AndroidRuntime(6334):  at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:881) 
03-13 15:21:18.863: E/AndroidRuntime(6334):  at android.graphics.drawable.Drawable.createFromXml(Drawable.java:818) 
03-13 15:21:18.863: E/AndroidRuntime(6334):  at android.content.res.Resources.loadDrawable(Resources.java:1915) 
03-13 15:21:18.863: E/AndroidRuntime(6334):  at android.content.res.TypedArray.getDrawable(TypedArray.java:601) 
03-13 15:21:18.863: E/AndroidRuntime(6334):  at android.view.View.<init>(View.java:3336) 
03-13 15:21:18.863: E/AndroidRuntime(6334):  at android.view.ViewGroup.<init>(ViewGroup.java:427) 
03-13 15:21:18.863: E/AndroidRuntime(6334):  at android.widget.LinearLayout.<init>(LinearLayout.java:176) 
03-13 15:21:18.863: E/AndroidRuntime(6334):  at android.widget.LinearLayout.<init>(LinearLayout.java:172) 
03-13 15:21:18.863: E/AndroidRuntime(6334):  ... 33 more 

XML佈局文件

<com.dzo.seattlesnightlife.ui.HeaderBar 
    android:id="@+id/baseHeaderBar" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentTop="true" /> 

<com.handmark.pulltorefresh.library.PullToRefreshListView 
    android:id="@+id/listViewSearch" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:layout_below="@+id/baseHeaderBar" 
    android:layout_marginBottom="55dp" 
    android:listSelector="@drawable/list_sel" 
    android:cacheColorHint="#00000000" 
    android:divider="@color/divider_list" 
    android:layout_marginTop="-3dp" 
    android:dividerHeight="2dp" /> 

<TextView 
    android:id="@+id/txtNoData" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_centerInParent="true" 
    android:text="@string/no_data" 
    android:textColor="@color/white" 
    android:textSize="18sp" 
    android:visibility="gone" /> 

<ScrollView 
    android:id="@+id/scrollLayout" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:layout_below="@+id/baseHeaderBar" 
    android:layout_marginBottom="60dp" 
    android:scrollbars="none" > 

    <LinearLayout 
     android:id="@+id/linScrollView" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:gravity="center|top" 
     android:orientation="vertical" > 

     <RelativeLayout 
      android:id="@+id/linImgAddress" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="5dp" 
      android:layout_marginRight="5dp" 
      android:layout_marginTop="5dp" 
      android:orientation="horizontal" > 

      <LinearLayout 
       android:id="@+id/linImgListingPhoto" 
       android:layout_width="143dp" 
       android:layout_height="143dp" 
       android:layout_marginTop="10dp" 
       android:background="@drawable/bg_description" 
       android:gravity="center" 
       android:orientation="vertical" > 

       <ImageView 
        android:id="@+id/imgListingPhoto" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:contentDescription="@string/d_desc" 
        android:scaleType="fitXY" /> 
      </LinearLayout> 

      <ImageButton 
       android:id="@+id/btnFav" 
       android:layout_width="30dp" 
       android:layout_height="30dp" 
       android:layout_gravity="top|left" 
       android:layout_marginTop="5dp" 
       android:background="@drawable/ic_fav" 
       android:contentDescription="@drawable/ic_fav" /> 

      <LinearLayout 
       android:id="@+id/linPromoTitle" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:layout_toRightOf="@+id/linImgListingPhoto" 
       android:layout_marginTop="10dp" 
       android:layout_marginLeft="5dp" 
       android:gravity="top" 
       android:orientation="vertical" > 

       <TextView 
        android:id="@+id/txtListingTitle" 
        android:layout_width="match_parent" 
        android:layout_height="40dp" 
        android:background="@drawable/bg_description" 
        android:gravity="center_vertical|center_horizontal" 
        android:textColor="@color/white" 
        android:textSize="20sp" /> 

       <LinearLayout 
        android:id="@+id/linAddressWebsite" 
        android:layout_width="match_parent" 
        android:layout_height="100dp" 
        android:layout_marginTop="3dp" 
        android:background="@drawable/bg_description" 
        android:orientation="vertical" > 

        <RelativeLayout 
         android:layout_width="match_parent" 
         android:layout_height="32dp" 
         android:id="@+id/relStoreAddress" 
         android:background="@drawable/highlight_rnd_top" > 

         <ImageView 
          android:id="@+id/imgIcMap" 
          android:layout_width="wrap_content" 
          android:layout_height="20dp" 
          android:layout_alignParentLeft="true" 
          android:layout_centerHorizontal="true" 
          android:layout_centerVertical="true" 
          android:layout_marginLeft="5dp" 
          android:contentDescription="@drawable/ic_map" 
          android:src="@drawable/ic_map" /> 

         <TextView 
          android:id="@+id/txtStoreAddress" 
          android:layout_width="match_parent" 
          android:layout_height="wrap_content" 
          android:layout_marginLeft="5dp" 
          android:layout_toRightOf="@+id/imgIcMap" 
          android:layout_centerVertical="true" 
          android:singleLine="true" 
          android:textColor="@color/white" 
          android:textSize="18sp" /> 

         <ImageView 
          android:layout_width="wrap_content" 
          android:layout_height="20dp" 
          android:layout_alignParentRight="true" 
          android:layout_centerHorizontal="true" 
          android:layout_centerVertical="true" 
          android:layout_marginRight="2dp" 
          android:contentDescription="@drawable/arrow_white" 
          android:src="@drawable/arrow_white" /> 
        </RelativeLayout> 

        <View 
         android:id="@+id/view2" 
         android:layout_width="fill_parent" 
         android:layout_height="1dp" 
         android:layout_marginBottom="0sp" 
         android:background="@color/line" /> 

        <RelativeLayout 
         android:id="@+id/relStoreContact" 
         android:layout_width="match_parent" 
         android:layout_height="34dp" 
         android:background="@drawable/highlight_mid" > 

         <ImageView 
          android:id="@+id/imgIcCall" 
          android:layout_width="wrap_content" 
          android:layout_height="20dp" 
          android:layout_marginLeft="5dp" 
          android:layout_alignParentLeft="true" 
          android:layout_centerHorizontal="true" 
          android:layout_centerVertical="true" 
          android:contentDescription="@drawable/ic_call" 
          android:src="@drawable/ic_call" /> 

         <TextView 
          android:id="@+id/txtStorePhone" 
          android:layout_toRightOf="@+id/imgIcCall" 
          android:layout_width="match_parent" 
          android:layout_height="wrap_content" 
          android:layout_marginLeft="2dp" 
          android:layout_centerVertical="true" 
          android:singleLine="true" 
          android:textColor="@color/white" 
          android:textSize="18sp" /> 

         <ImageView 
          android:layout_width="wrap_content" 
          android:layout_height="20dp" 
          android:layout_alignParentRight="true" 
          android:layout_centerHorizontal="true" 
          android:layout_centerVertical="true" 
          android:layout_marginRight="2dp" 
          android:contentDescription="@drawable/arrow_white" 
          android:src="@drawable/arrow_white" /> 
        </RelativeLayout> 

        <View 
         android:id="@+id/view3" 
         android:layout_width="fill_parent" 
         android:layout_height="1dp" 
         android:layout_marginBottom="0sp" 
         android:background="@color/line" /> 

        <RelativeLayout 
         android:layout_width="match_parent" 
         android:layout_height="32dp" 
         android:id="@+id/relStoreWeb" 
         android:background="@drawable/highlight_rnd_bottom" > 

         <ImageView 
          android:id="@+id/imgIcWeb" 
          android:layout_width="wrap_content" 
          android:layout_height="20dp" 
          android:layout_alignParentLeft="true" 
          android:layout_centerHorizontal="true" 
          android:layout_centerVertical="true" 
          android:layout_marginLeft="5dp" 
          android:contentDescription="@drawable/ic_web" 
          android:src="@drawable/ic_web" /> 

         <TextView 
          android:layout_toRightOf="@+id/imgIcWeb" 
          android:id="@+id/txtStoreWebsite" 
          android:layout_width="match_parent" 
          android:layout_height="wrap_content" 
          android:layout_centerVertical="true" 
          android:singleLine="true" 
          android:textColor="@color/white" 
          android:textSize="18sp" 
          android:text="@string/visit_web"/> 

         <ImageView 
          android:layout_width="wrap_content" 
          android:layout_height="20dp" 
          android:layout_alignParentRight="true" 
          android:layout_centerHorizontal="true" 
          android:layout_centerVertical="true" 
          android:layout_marginRight="2dp" 
          android:contentDescription="@drawable/arrow_white" 
          android:src="@drawable/arrow_white" /> 
        </RelativeLayout> 
       </LinearLayout> 
      </LinearLayout> 
     </RelativeLayout> 

     <LinearLayout 
      android:id="@+id/linDescInfo" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_gravity="top" 
      android:layout_marginTop="5dp" 
      android:orientation="vertical" > 

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

      <LinearLayout 
       android:id="@+id/linStoreDescTitle" 
       android:layout_width="match_parent" 
       android:layout_height="35dp" 
       android:layout_gravity="center" 
       android:gravity="center|top" 
       android:orientation="vertical" 
       android:layout_marginLeft="5dp" 
       android:layout_marginRight="5dp" 
       android:layout_marginTop="5dp" 
       android:visibility="gone" > 

       <TextView 
        android:id="@+id/txtDescTitle" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:background="@drawable/bg_description" 
        android:gravity="center" 
        android:paddingLeft="5dp" 
        android:paddingRight="5dp" 
        android:singleLine="true" 
        android:text="@string/d_desc" 
        android:textColor="@color/white" 
        android:textSize="20sp" /> 
      </LinearLayout> 

      <LinearLayout 
       android:id="@+id/linStoreDesc" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_gravity="top" 
       android:layout_marginLeft="5dp" 
       android:layout_marginRight="5dp" 
       android:layout_marginTop="5dp" 
       android:background="@drawable/bg_desc" 
       android:gravity="center_horizontal" 
       android:orientation="vertical" 
       android:visibility="gone" > 

       <com.dzo.seattlesnightlife.ui.ExpandablePanel 
        android:id="@+id/descPanel" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:orientation="vertical" 
        custom:animationDuration="25" 
        custom:collapsedHeight="80dp" 
        custom:content="@+id/txtDesc" 
        custom:handle="@+id/expand" > 

        <TextView 
         android:id="@id/txtDesc" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:layout_gravity="center" 
         android:textSize="18sp"/> 

        <View 
         android:id="@+id/view4" 
         android:layout_width="fill_parent" 
         android:layout_height="1dp" 
         android:layout_marginBottom="0sp" 
         android:background="@color/line"/> 

        <RelativeLayout 
         android:id="@id/expand" 
         android:layout_width="fill_parent" 
         android:layout_height="wrap_content" 
         android:layout_marginTop="5dp" 
         android:background="@drawable/txt_highlight" 
         android:visibility="gone"> 

         <TextView 
          android:id="@+id/txtShowMoreLess" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:layout_centerInParent="true" 
          android:text="@string/show_more" 
          android:textColor="@color/white" 
          android:textSize="18sp" 
          android:textStyle="bold" 
          android:visibility="gone" /> 

         <ImageView 
          android:id="@+id/imgMoreLess" 
          android:layout_width="20dp" 
          android:layout_height="20dp" 
          android:layout_centerInParent="true" 
          android:layout_toRightOf="@+id/txtShowMoreLess" 
          android:background="@drawable/arrow_down" 
          android:contentDescription="@drawable/arrow_down" 
          android:visibility="gone" /> 
        </RelativeLayout> 
       </com.dzo.seattlesnightlife.ui.ExpandablePanel> 
      </LinearLayout> 

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

      <LinearLayout 
       android:id="@+id/linShare" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginLeft="3dp" 
       android:layout_marginRight="3dp" 
       android:layout_marginTop="8dp" 
       android:gravity="top|center_horizontal" 
       android:orientation="vertical" > 

       <LinearLayout 
        android:id="@+id/linStoreShareBox" 
        android:layout_width="match_parent" 
        android:layout_height="35dp" 
        android:layout_gravity="top" 
        android:gravity="center_horizontal" 
        android:orientation="vertical" > 

        <TextView 
         android:id="@+id/txtStoreShareTittle" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:background="@drawable/bg_description" 
         android:gravity="center|center_vertical" 
         android:paddingLeft="5dp" 
         android:paddingRight="5dp" 
         android:singleLine="true" 
         android:text="@string/d_share" 
         android:textColor="@color/white" 
         android:textSize="20sp" /> 
       </LinearLayout> 

       <include layout="@layout/share_lay_part" /> 
      </LinearLayout> 
     </LinearLayout> 
    </LinearLayout> 
</ScrollView> 

<com.dzo.seattlesnightlife.ui.FooterBar 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:id="@+id/baseFooterBar"/> 
</RelativeLayout> 

每當我跑我在大屏幕設備或模擬器的應用程序,我得到這個weired例外。通過堆棧,當我檢查線路號碼。 29在XML中,textView是android:layout_height。行號的應用程序崩潰的活動是setContentView()OutOfMemoryError表示我的繪圖有問題。所以,我調整了我的drawable,但沒有任何幫助。找不到崩潰的真正原因。

我的Java file。對不起,因爲它超過了身體限制,所以無法發佈它,因爲它有大約5k行代碼,所以我定製了它。

好吧,當我將堆大小增加到48 MB的應用程序沒有崩潰,但與16 MB的堆,它仍然崩潰。

+0

它是不能膨脹你的自定義視圖 – Pragnani 2013-03-13 10:17:44

回答

12

它會更好,如果u改變圖像的大小你使用。可能是那些尺寸不適用於您使用的設備。

+0

謝謝,但我已經嘗試過了。重新無處可去。 – Nitish 2013-03-13 12:16:26

+0

你在模擬器或移動設備上使用它? – 2013-03-13 12:27:05

+0

對於大屏幕,我正在模擬器上運行測試。由於我沒有大屏幕設備 – Nitish 2013-03-13 12:37:50

1

你的XML錯誤是隻有主錯誤的結果:的OutOfMemoryError

只要你沒有找到提高你的內存管理的線索,您將有論文樣的錯誤(XML或其他)

你的XML是正確的,在它裏面沒有錯誤,該行29「點」在當OutOfMemoryError異常發生

您的應用程序是
+0

所以,我應該怎麼做下一步,我應該去使用MAT? – Nitish 2013-03-13 11:02:51

+0

你必須考慮**強制垃圾收集**,**位圖管理**(創建/緩存/銷燬/最大尺寸)...等等 – StephaneT 2013-03-13 11:33:56

+0

我沒有創建任何明確的位圖。我所有的drawable都是內部資源。那麼,我該如何管理它們呢? – Nitish 2013-03-13 12:07:00

0

我也認爲OutOfMemoryErrorlogcat報告的決定性部分。我將Android虛擬設備的VM堆從16MB增加到32 MB。現在它可以工作。

+0

這很好,但用戶應該使用真實設備上的應用程序,而不是仿真器恕我直言。 – Nitish 2013-08-20 06:54:15

0

我有一個類似的問題,它選擇大的佈局 - 比屏幕大,它縮放到位圖。 然後出現內存不足。 我製作的圖像尺寸較小的背景和按鈕,它出現了。 然後我看到一個屏幕太大的佈局。

相關問題