2014-04-22 59 views
0

我有一個奇怪的問題,我的代碼在某些設備上工作,但在股票S3與api 18(Androdi 4.3)不起作用(引起:android.view。 InflateException)二進制XML文件行#23:錯誤充氣類<unknown>

這是我的logcat

04-21 00:53:52.150: E/(32638): Device driver API match 
04-21 00:53:52.150: E/(32638): Device driver API version: 23 
04-21 00:53:52.150: E/(32638): User space API version: 23 
04-21 00:53:52.155: E/(32638): mali: REVISION=Linux-r3p2-01rel3 BUILD_DATE=Wed Oct 9  21:05:57 KST 2013 
04-21 00:54:00.985: E/dalvikvm-heap(32638): Out of memory on a 3905296-byte allocation. 
04-21 00:54:01.035: E/AndroidRuntime(32638): FATAL EXCEPTION: main 
04-21 00:54:01.035: E/AndroidRuntime(32638): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.keyren.game/game_package_dev.Profile_View}: android.view.InflateException: Binary XML file line #23: Error inflating class <unknown> 
04-21 00:54:01.035: E/AndroidRuntime(32638): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2295) 
04-21 00:54:01.035: E/AndroidRuntime(32638): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2349) 
04-21 00:54:01.035: E/AndroidRuntime(32638): at android.app.ActivityThread.access$700(ActivityThread.java:159) 
04-21 00:54:01.035: E/AndroidRuntime(32638): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316) 
04-21 00:54:01.035: E/AndroidRuntime(32638): at android.os.Handler.dispatchMessage(Handler.java:99) 
04-21 00:54:01.035: E/AndroidRuntime(32638): at android.os.Looper.loop(Looper.java:176) 
04-21 00:54:01.035: E/AndroidRuntime(32638): at android.app.ActivityThread.main(ActivityThread.java:5419) 
04-21 00:54:01.035: E/AndroidRuntime(32638): at java.lang.reflect.Method.invokeNative(Native Method) 
04-21 00:54:01.035: E/AndroidRuntime(32638): at java.lang.reflect.Method.invoke(Method.java:525) 
04-21 00:54:01.035: E/AndroidRuntime(32638): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046) 
04-21 00:54:01.035: E/AndroidRuntime(32638): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862) 
04-21 00:54:01.035: E/AndroidRuntime(32638): at dalvik.system.NativeStart.main(Native Method) 
04-21 00:54:01.035: E/AndroidRuntime(32638): Caused by: android.view.InflateException: Binary XML file line #23: Error inflating class <unknown> 
04-21 00:54:01.035: E/AndroidRuntime(32638): at android.view.LayoutInflater.createView(LayoutInflater.java:626) 
04-21 00:54:01.035: E/AndroidRuntime(32638): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java: 56) 
04-21 00:54:01.035: E/AndroidRuntime(32638): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:675) 
04-21 00:54:01.035: E/AndroidRuntime(32638): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:700) 
04-21 00:54:01.035: E/AndroidRuntime(32638): at android.view.LayoutInflater.rInflate(LayoutInflater.java:761) 
04-21 00:54:01.035: E/AndroidRuntime(32638): at android.view.LayoutInflater.inflate(LayoutInflater.java:498) 
04-21 00:54:01.035: E/AndroidRuntime(32638): at android.view.LayoutInflater.inflate(LayoutInflater.java:398) 
04-21 00:54:01.035: E/AndroidRuntime(32638):  at android.view.LayoutInflater.inflate(LayoutInflater.java:354) 
04-21 00:54:01.035: E/AndroidRuntime(32638): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:361) 
04-21 00:54:01.035: E/AndroidRuntime(32638): at android.app.Activity.setContentView(Activity.java:1956) 
04-21 00:54:01.035: E/AndroidRuntime(32638): at game_package_dev.Profile_View.onCreate(Profile_View.java:44) 
04-21 00:54:01.035: E/AndroidRuntime(32638): at android.app.Activity.performCreate(Activity.java:5372) 
04-21 00:54:01.035: E/AndroidRuntime(32638): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104) 
04-21 00:54:01.035: E/AndroidRuntime(32638):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2257) 
04-21 00:54:01.035: E/AndroidRuntime(32638):  ... 11 more 
04-21 00:54:01.035: E/AndroidRuntime(32638): Caused by: java.lang.reflect.InvocationTargetException 
04-21 00:54:01.035: E/AndroidRuntime(32638):  at java.lang.reflect.Constructor.constructNative(Native Method) 
04-21 00:54:01.035: E/AndroidRuntime(32638): at java.lang.reflect.Constructor.newInstance(Constructor.java:417) 
04-21 00:54:01.035: E/AndroidRuntime(32638): at android.view.LayoutInflater.createView(LayoutInflater.java:600) 
04-21 00:54:01.035: E/AndroidRuntime(32638): ... 24 more 
04-21 00:54:01.035: E/AndroidRuntime(32638): Caused by: java.lang.OutOfMemoryError 
04-21 00:54:01.035: E/AndroidRuntime(32638): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method) 
04-21 00:54:01.035: E/AndroidRuntime(32638): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:596) 
04-21 00:54:01.035: E/AndroidRuntime(32638): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:444) 
04-21 00:54:01.035: E/AndroidRuntime(32638): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:832) 
04-21 00:54:01.035: E/AndroidRuntime(32638): at android.content.res.Resources.loadDrawable(Resources.java:2988) 
04-21 00:54:01.035: E/AndroidRuntime(32638): at android.content.res.TypedArray.getDrawable(TypedArray.java:602) 
04-21 00:54:01.035: E/AndroidRuntime(32638): at android.view.View.<init> (View.java:3563) 
04-21 00:54:01.035: E/AndroidRuntime(32638): at android.view.ViewGroup.<init> (ViewGroup.java:475) 
04-21 00:54:01.035: E/AndroidRuntime(32638): at android.widget.LinearLayout.<init>(LinearLayout.java:176) 
04-21 00:54:01.035: E/AndroidRuntime(32638): at android.widget.LinearLayout. <init>(LinearLayout.java:172) 
04-21 00:54:01.035: E/AndroidRuntime(32638): ... 27 more 

,這是我的xml文件,無法理解我的問題,爲什麼只用S3不工作我有一個S3太多,但定製ROM,並且完美地工作

<?xml version="1.0" encoding="utf-8"?> 
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/profileScreen" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="@drawable/screen_bk" 
    android:gravity="center_horizontal|center" 
    android:orientation="vertical" > 

    <TextView 
     android:id="@+id/header_profile" 
     style="@style/AppBaseTheme" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@drawable/profileheader" 
     android:gravity="center" 
     android:text="@string/info_prof" 
     android:textAppearance="?android:attr/textAppearanceLarge" 
     android:textColor="@android:color/background_dark" 
     android:textStyle="bold" /> 

    <LinearLayout 
     android:id="@+id/Player_info" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_below="@+id/header_profile" 
     android:background="@drawable/spaceinfo" 
     android:orientation="vertical" 
     android:paddingTop="25dp" > 

     <TextView 
      android:id="@+id/Name_Field" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="24dp" 
      android:text="@string/Name" /> 

     <TextView 
      android:id="@+id/Lv_Field" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="24dp" 
      android:layout_marginTop="1dp" 
      android:text="@string/complete_levels" /> 

     <TextView 
      android:id="@+id/Num_Chars_Unlock" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="24dp" 
      android:layout_marginTop="1dp" 
      android:text="@string/Chars_Unlock" /> 

     <TextView 
      android:id="@+id/Num_BGs_Unlock" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="24dp" 
      android:layout_marginTop="1dp" 
      android:text="@string/BGs_Unlock" /> 

     <TextView 
      android:id="@+id/Text_win" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="24dp" 
      android:layout_marginTop="1dp" 
      android:text="@string/Text_Win" /> 

     <TextView 
      android:id="@+id/Text_Lose" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="24dp" 
      android:layout_marginTop="1dp" 
      android:text="@string/Text_Lose" /> 
    </LinearLayout> 

    <FrameLayout 
     android:id="@+id/field1" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignTop="@+id/Player_info" 
     android:layout_marginTop="27dp" 
     android:layout_toRightOf="@+id/Player_info" 
     android:background="@android:color/darker_gray" > 

     <TextView 
      android:id="@+id/space_name" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/empty" /> 

     <EditText 
      android:id="@+id/textedit_new_name" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="left|center|center_vertical" 
      android:layout_margin="15dp" 
      android:inputType="textPersonName" 
      android:maxLength="15" 
      android:visibility="gone" 
      android:width="215dp" /> 

     <Button 
      android:id="@+id/save_button" 
      style="?android:attr/buttonStyleSmall" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="right|center_vertical|center_horizontal|center" 
      android:gravity="center_vertical|center" 
      android:text="@string/save_edit" 
      android:visibility="gone" /> 
    </FrameLayout> 

    <FrameLayout 
     android:id="@+id/field2" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignTop="@+id/Player_info" 
     android:layout_below="@+id/field1" 
     android:layout_marginTop="55dp" 
     android:layout_toRightOf="@+id/Player_info" 
     android:background="@android:color/black" > 

     <TextView 
      android:id="@+id/space_lvs" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/empty" /> 
    </FrameLayout> 

    <FrameLayout 
     android:id="@+id/field3" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/field2" 
     android:layout_marginTop="5dp" 
     android:layout_toRightOf="@+id/Player_info" 
     android:background="@android:color/holo_blue_bright" > 

     <TextView 
      android:id="@+id/chars_unlock_space" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/empty" /> 
    </FrameLayout> 

    <FrameLayout 
     android:id="@+id/field4" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" 
     android:layout_below="@+id/field3" 
     android:layout_marginTop="5dp" 
     android:layout_toRightOf="@+id/Player_info" 
     android:background="@android:color/holo_green_dark" > 

     <TextView 
      android:id="@+id/bgs_unlock_space" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/empty" /> 
    </FrameLayout> 

    <FrameLayout 
     android:id="@+id/field5" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" 
     android:layout_below="@+id/field4" 
     android:layout_marginTop="5dp" 
     android:layout_toRightOf="@+id/Player_info" 
     android:background="@android:color/holo_orange_dark" > 

     <TextView 
      android:id="@+id/space_win" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/Num_Win" /> 
    </FrameLayout> 

    <FrameLayout 
     android:id="@+id/field6" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignLeft="@+id/field5" 
     android:layout_alignParentRight="true" 
     android:layout_below="@+id/field5" 
     android:layout_marginTop="5dp" 
     android:background="@android:color/holo_purple" > 

     <TextView 
      android:id="@+id/space_lose" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/Num_Lose" /> 

    </FrameLayout> 

    <Space 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" /> 

    <Space 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" /> 

    <FrameLayout 
     android:id="@+id/field7" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" 
     android:layout_alignParentTop="true" > 

     <ImageView 
      android:id="@+id/space_avatar" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginRight="18dp" 
      android:layout_marginTop="10dp" 
      android:contentDescription="@string/avatar" 
      android:src="@drawable/av0" /> 

    </FrameLayout> 

</RelativeLayout> 
+1

'產生的原因:java.lang.OutOfMemoryError' sacle來的像'av0'。 – Raghunandan

+0

感謝您的回覆^^但如何? – user3559642

+1

閱讀本文http://developer.android.com/training/displaying-bitmaps/index.html – Raghunandan

回答

0

嘗試在AndroidManifest.xml中添加此:

<application android:largeHeap="true"> 
相關問題